doodlewind / bumpover Goto Github PK
View Code? Open in Web Editor NEW๐ง Async data transforming with simple rules.
License: MIT License
๐ง Async data transforming with simple rules.
License: MIT License
Bug
https://jsfiddle.net/hp7n1k76/
Return weird result bumping '{}'
Return '{}'
as result (this is not void, so defaultValue
should not apply).
With v0.4.0
released, bumpover is pretty close for an announcement. Following work required:
juejin.im
badge afterwards..github
template.Nice to have:
Let's make this happen!
We have only one test case for now, which is poor. To ensure reliable releases, adding test cases covering these parts are planned:
Bumpover
bumper.bump
with empty databumper.bump
with empty rulebumper.bump
with invalid rulebumper.bump
with invalid databumper.bump
with nested data and rule updating node valuebumper.bump
with nested data and rule updating node keybumper.bump
with nested data and multi rulesbumper.bump
with invalid structbumper.bump
with nested data and one rule structbumper.bump
with nested data and multi rule structsbumper.bump
with invalid optionbumper.bump
with stop action on rootbumper.bump
with stop action on nodebumper.bump
with invalid actionbumper.bump
with ignore unknown on nodebumper.bump
with ignore unknown on rootbumper.bump
with default valuebumper.bump
with async resolvebumper.bump
with childKey
unmatched node (allow stub)bumper.test
bumper.assert
XMLBumpover
bumper.bump
with empty databumper.bump
with namespace tagsbumper.bump
with CDATA tagsbumper.bump
with stop actionbumper.bump
with ignore unknownJSONBumpover
bumper.bump
with empty data (throws for now)bumper.bump
with nested data and multi rulesBumpover is designed to migrate data at first. For such tasks, writing unit tests is critical to ensure reliablity. Since bumper.bump
is async, it may be confusing testing it.
A new post introducing how to write test for complex taasks in ./docs
is nice to have.
Since we have added unit tests in #19, before next minor release, it makes sense integrating CI coverage service with its badge into README, which looks more reliable :-)
In a complex data structure, the fields expressing a node's children may differ in different types of nodes. So it's useful to have each rule specify its childrenKey
for traversing. This field is optional, with options.childrenKey
as default.
Moreover, the childrenKey
API looks verbose, which can be simplified with a better name. For nodes without matched childrenKey
, we also need a way handling them.
UMD build is necessay for using in browser environment, e.g., JSFiddle. Requirement:
<script>
tag in production.Following documentation is supposed to ship with next minor release:
Bug
https://jsfiddle.net/1u29rkjk/
Error thrown on { tag: 'div', children: 123 }
:
index.js:81 Uncaught (in promise) TypeError: children.map is not a function
at bumpRoot (index.js:81)
at rule.update.then.result (index.js:170)
at <anonymous>
This is undefined behaviour for now indeed. Any ideas for expected result?
Feature
For now the nodes with no rules matched will be kept or ignored, without being handled by any custom rules. So it seems better to add a "default" update handler for such nodes, in this case we can even remove the "ignoreUnknown", giving more flexibility to user.
Feature
It's better replacing the new Promise()
with Promise.resolve
in trivial cases.
Feature
We can add options.beforeMatch(node)
without side effect, which allows some general analysis of the document.
For now README is enriched and API reference is added. For an easy to use library, a vivid guide is also critical. It's good to show following examples:
action: 'stop'
to return beforehand.ignoreUnknown
to keep or discard unknown nodes.Some of them can be picked out as working JSFiddle examples. Moreover, the default example in README is not hitting pain points. Using a better one?
Bug
require('bumpover')
throws error.
Dependencies should be installed automatically.
For now we need to support following methods:
bumper.bump
bumper.assert
bumper.test
rule.struct
bumper.bump
should implement following options:
silent
defaultValue
With following bumpovers out of the box:
class Bumpover
class XMLBumpover
class JSONBumpover
Features planned with low priority for recent releases:
validate
(do with schema)Currently errors from superstruct are thrown as string, which is overkill. Providing a consistent error format sounds to be a better solution.
This feature is of relative low priority for now, since we don't have enough real world cases addressing it.
For now examples are built by npm scripts, which was a workaround for build test. Now that Ava is integreted, this is no longer necessary. So we need new way running examples. Requirements:
package.json
.package.json
or simply run in node.examples
folder.XML dependencies are not provided in JSFiddle demo.
Bumpover walks through data in DFS way. To customize new data structure after bumping, one approach is to use the Result.action
field.
Each Result
resolved by bumpNode
has one of actions in below:
next
: Continue recursive traversing.skip
: Recognize current node as leaf node, return from traversing.In this case we can preserve certain complex structure in bumped data, i.e., macro tags in rich text xml format.
Feature
For tree shaking it'll be better bundle Bumpover with package.module
.
Feature
We have a well defined rule runner for now, whereas for a large doc shape, writing rules in flat array may not scale up as expected.
One solution is to expose the getRule
to user, leaving them to get and even compose rules, like what chainCommand
did in ProseMirror. But then rules
may not be enforced as flat array.
This is a very premature idea. New API may change whenever better thoughts are proposed.
For now we only have a catalog in reference.md
. It's necessary to add up existing API into it.
Currently the traversing logic is not guarded by test cases. For a mature library, following points are necessary:
devDependencies
integration.Currently when bumping ''
in JSONBumpover
, an error is thrown by JSON.parse
. It may be nicer handling them in a more elegant way.
This feature is pretty good to have if it doesn't introduce large refactoring.
Currently an action
is required for each rule, which is verbose in most of the cases. Making this field optional can lead to terser rules. The default action should be 'next'
.
This change is supposed to be landed after we have reliable unit tests.
Feature
The result returned by rule.struct
is discarded.
Use the validated result as newNode
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.