Giter Club home page Giter Club logo

keypather's People

Contributors

cflynn07 avatar erasmo-marin avatar greenkeeper[bot] avatar justsml avatar nathan219 avatar tjmehta avatar yaronyam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

keypather's Issues

Boast about not using eval :)

Hi @tjmehta. TBH I was a little wary of using keypather. Looking at the impressive scope of functionality, I was sure you use eval or new Function or something of that kind for retrieving and setting the properties :)

I scanned the source and found out you don't. Wow! πŸ‘ Why not say it in the readme or somewhere? :)

Does not create sub-objects properly on set

var keypath = require('value-for-keypath')();
undefined
var obj = {};
undefined
keypath.set(obj, 'lms_step.lms_quiz._id', 'a');
'a'
obj
{ 'lms_step.lms_quiz': { _id: 'a' } }

Accept an array

Instead of "a.b.c" keypather could accept an array like ["a", "b", "c"]. As object-path does it.

Here's why.

  • it coughs up on setting things like {"[key]": "value"}
  • when you have:
var keys = ["a", "[b]", "c()", "'d\''"];

…it seems very wrong to do:

keypather.set(...
  , keys.map(function (key) {
    return "['" + key.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "']"
    }).join("")
  );

…when you could just:

keypather.set(..., keys);

Library does not support Json Keys with characters '-'

I was trying to use the Library for parsing a folder structure having set of files and creating an object out of it.

I get error for a key which has hyphen in file name
if (!/^[A-Za-z0-9_$]$/.test(character)) throw new Error(parseErrorMessage(state, 'invalid dot key')) ^ Error: Error parsing keypath 'how-to' at char 4 '-': invalid dot key

Undefined values vs undefined properties

> a = {} 
> keypather.get(a, 'PROPERTY.THAT.DOESNT.EXIST')
null
> keypather.get(a, 'PROPERTY_THAT_DOESN_EXIST')
undefined

This seems like weird behavior to me. I would have expected either both to be null or both to be undefined.

I understand that it's probably a bit too late to change this, but thought I'd point it out. It seems to me that a value that doesn't exist should always return undefined since it's... well... undefined, but I might be missing something.

More modular design

I was trying to figure out the best way to make the code more modular/monad-like.
So, for example let's consider the path splitting features as chain-able modules: dottedPaths, arrayPaths, functionPaths, or something like customPathMapper

This would make it easier to exclude, say, function-path features (XS exploits come to mind), not to mention it'd be easier to make custom keypather builds. Like a light-weight read-only path checker for the browser would be really handy, especially on mobile.

Anyway, I was just wondering what @tjmehta thoughts are on this.

Thanks for the awesome lib!

// mock example:
var getPath = require('keypather/get'); // note: get.js could be used by browserify to get only the dependencies required for reading objects
console.log('Email: ', getPath(user, 'contactInfo.email');

An in-range update of debug is breaking the build 🚨

Version 3.2.3 of debug was just published.

Branch Build failing 🚨
Dependency debug
Current Version 3.2.2
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

debug is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 1 commits.

  • 700a010 re-introduce node.js (root file) (ref #603)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Expanding array

Hi,

keypath.expand behavior is pretty weird with expanding an array.

The output of this:

keypath.expand(keypath.flatten({
   notes: ["hello", "this"]
}));

is { "0": "hello", "1": "this" }

Flatten function filters out empty arrays.

import flatten from "keypather/flatten";

const myObj = { foo: [] }
const myOtherObj = { foo: ['bar'] }

flatten(myObj) // => {} Missing "foo" key
flatten(myOtherObj) // => { 'foo[0]': 'bar' }

🚨 Potential Security Vulnerability - huntr.dev

⚠️ Potential Vulnerability in keypather

πŸ‘‹ Hello, @tjmehta - @Nav-Prak has disclosed a potential vulnerability in your repository. To validate or invalidate this potential vulnerability, please visit https://huntr.dev/bounties/2-npm-keypather and join our community in helping secure open-source code.


☎️ Need further support?

Come and join us on our Discord and a member of our team will be happy to help! πŸ€—

cc - @JamieSlome

ES6 import support

Hi, it would be great if import support is improved and documented.

Right now it's possible to use ES6 import with keypather this way, but it's not clean and you create a new instance every time you need it:

import { default as keypather } from 'keypather';

let myKeypather = keypather();

something like this would be better:

import keypather from 'keypather';
//if you need to set options
keypather.setOptions({...});

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.