kaelinator / hopps Goto Github PK
View Code? Open in Web Editor NEWComplex data manipulation made easy
License: MIT License
Complex data manipulation made easy
License: MIT License
Instead of simply returning an undefined value, the user should be able to specify whether or not an error is thrown when something goes wrong.
Something like:
burrow.quietly.get( ... )
should not throw errors, but return undefined,
while:
burrow.loudly.get( ... )
should throw a descriptive error.
Semantics are up for debate.
The user should be able to delete an object's properties:
hopps.delete('a.b', { a: { b: 99 } })
=> { a: {} }
As well as an array's contents:
hopps.delete('[4..-1]', [0, 1, 1, 2, 3, 5, 8])
=> [0, 1, 1, 2, 8]
If the user does not want to override a value, but would like a given value to be placed in the value's absence, the user should be able to easily specify.
For example:
hopps.set('a.b', { a: { b: 'hello!' } }, 'hi!', { override: true })
would yield
{
a: {
b: 'hi!'
}
}
while
hopps.set('a.b', { a: { b: 'hello!' } }, 'hi!', { override: false })
would yield
{
a: {
b: 'hello!'
}
}
and
hopps.set('a.b', { a: { } }, 'hi!', { override: false })
would yield
{
a: {
b: 'hi!'
}
}
Instead of using a string every time, it'd be nice if the user could pass a RegEx for the template, and have the same functionality.
As in, hopps.get('a.b', { a: { b: 'hi!' } })
and hopps.get(/a.b/, { a: { b: 'hi!' } })
both would yield 'hi!'
.
The user should be able to capture data, along with parent data, using parentheses (()
).
With objects, the data is kept wrapped within its parents:
const data = {
a: {
b: {
c: 'hi!',
d: 16
},
f: 42
}
}
hopps.get('a.(b.c)', data) // => { b: { c: 'hi!' } }
With arrays, the data is kept wrapped within its index:
hopps.get('([1, -1])', ['a', 'b', 'c', 'd']) // => [ , 'b', , 'd']
The current README will likely get out of hand very quickly. Separate files for each method will become increasingly necessary. Perhaps they'd fit well in a docs/
directory!
A user should be able to write:
hopps.set('a.b.c', { d: 1 }, 'hi!')
and expect:
{
a: {
b: {
c: 'hi!'
}
}
d: 1
}
Also, data retrieval should be permitted:
hopps.get('a.b.c', { a: { b: { c: 'hi!' } } })
yielding 'hi!'
A pipeline would be cool to implement as for the actual use of the library:
const f = hopps
.set(/[-1]/)
.set(/a.b/)
f(5)([1, 2])({}) // => { a: { b: [1, 2, 5] } }
The user should be able to deal with arrays just as easily as with objects using brackets.
For example,
hopps.set('[0..2]', [], 'hi!')
should yield
[ 'hi!', 'hi!', 'hi!' ]
And
hopps.get('a[0..1].b', { a: [ { b: 55, c: 42 }, { b: 9, c: 42 } ] })
should result in
[ 55, 9 ]
Array operations should follow haskell's syntax.
For newcomers, a README is necessary.
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.