Giter Club home page Giter Club logo

deep-grep's People

Contributors

janearc avatar

Stargazers

 avatar  avatar

Watchers

 avatar

deep-grep's Issues

Deep clone based on a match

Can we have a deep clone based on a match

e.g.

var haystack = [
    'zebra', 'lion', [
        'tiger', 'unicorn', 'emperor penguin'
    ],
    'leprechaun',
    'cockerel'
];

var needles  = dg.pickDeep( list, function (t) {
    if (new RegExp( ('(unicorn|leprechaun)s?' ).test(t))) return true
} );

yields:

['leprechaun',['unicorn']];

return-objects parameter

So if we have a list that looks like:

[
  { 'user-name': 'jane', 'user-id': 692, 'home': '/usr/people/jane' },
  { 'user-name': 'federico', 'user-id': 693, 'home': '/usr/people/federico' },
]                                                                               

right now dg would (I think…) return the hash tuples like:

[
  { 'user-name': 'jane' },
  { 'user-id': '693' },
  { 'home': '/usr/people/jane' }
]                                                                               

if we called it like

var results = require( 'deep-grep' ).deeply( list, /[a3]/, {
  'return-hash-tuples': true,
  'check-hash-values': true,
  'check-hash-keys': true
} );

which is what I want some of the time, but I also want to be able to return the whole object (so, { 'user-name': 'jane', 'user-id': 692, 'home': '/usr/people/jane' }, rather than tuples/kv pairs). The logic for this is not straightforward because there's no state kept in deeply about the object it's grepping; rather it just keeps track of the value and the key. I think.

merge jagrep

I think it's probably best to just merge in jagrep. There's a lot of overlap. It's all listy things to do.

in() should take lists as test

  • var within = dg.in( [ 1, 2, 3, 4], 1 ); // true
  • var within = dg.in( [ 1, 2, 3, 4], [ 2, 3 ] ); // true
  • var within = dg.in( [ 1, 2, 3, 4], [ 2, 3, 4, 5 ] ); // returns [ 2, 3, 4 ] ?

coalesce-object

var from = {
  foo: 'bar',
  baz: 'bletch'
}

var to = {
  qip: 'quux'
}

this presents an ugliness in the way javascript handles objects. There is no way to refer to multiple values of an object by its keys.

dg.coalesce_object( from, to, {
  'keys': [ 'foo', 'baz' ],
  'return-clone': true
}  )

would allow me to make a clone that looked like:

{
  qip: 'quux'
  foo: 'bar',
  baz: 'bletch'
}

and alternatively if return-clone is false, to would be munged.

Update readme

Some of the wording is awkward, syntax hilighting is not enabled.

check-object-methods *doesn't exist*

This parameter is specified in the docs but I never got around to writing it, and is considered by me to be core functionality (because there is so much intermingling of keys/methods in objects in js).

flatten()

Obviously since deeply flattens, and I use this functionality elsewhere, it would be good to just expose that functionality.

unique()

So ordinarily I do something like:

my $unique = [ keys %{ map { $_ => 1 } @some_list } ]

To get the unique elements of a list. Obviously this idiom won't work for lots of reasons in node, but it would be nice to be able to add a { unique: true } parameter to deeply(). In fact, I could probably use this today.

unwrap promises

There is no real way to grep through a promise. Since Sendak uses promises extensively, dg is unwelcome in a large number of places. Fix that.

override "push" and "pop" methods

In theory it should be possible to override the "push" and "pop" methods that deep-grep uses to e.g., pull records… out of riak. or out of a hadoop cluster. or whatever. but there's no reason the list has to be an actual in-memory list; it can just be a "list-like thing in the sky."

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.