Coder Social home page Coder Social logo

hopps's People

Contributors

kaelinator avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hopps's Issues

Allow whether or not to throw errors

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.

Delete object and array properties

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]

Add underwrite option to `.set`

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!'
  }
}

Allow Regular Expression for template

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!'.

Allow capturing

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']

More structured README

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!

Allow data insertion and retrieval from template

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!'

Function chaining

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] } }

Allow burrowing of arrays

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.

README

For newcomers, a README is necessary.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.