Comments (5)
Quick thoughts: I like this idea a lot (splitting each operation into it's own module/file)
from keypather.
👍
I think #10 could be solved with this one too.
from keypather.
Hey @tjmehta ... In trying to decompose the index.js and it's methods, I've made the code a little uglier I feel. (I'll reference my branch when I load it... )
Let me explain where I'm at: I love seeing solid use of prototype like this, however I'm currently breaking it up into more basic utility-function design ( sub-classes and prototype might be overkill for this. Ultimately I think a skinny+modular design will come from using a direct require('./lib/xyz')
design - accessing state-less/instance-less feature methods). So index.js would look like a little like this: exports.get = require('./lib/get')
this would make it 'instance-free' and each call's lifetime is clearly scoped: run's in it's own closure, allowing better garbage collection
Current progress/thoughts
- I've been re-factoring the
getValue
fn and it's dependent method chain,- Moved fns: handleKey, handleFunction, handleBrackets under getValue
- Can
in()
andhas()
be updated to use get() directly?
from keypather.
Other thoughts
In order to design (what I think is) an ideal plugin model, I usually assume an infinite possible # of plugins... While this is probably not a likely requirement for a module with most functionality included - hopefully this will just make code more tightly scoped)
I typically design a plugin interface with members like: run(obj)
, int priority
(maybe a hasRun(obj)
et al.)
For keypather, I think a plugin interface method like canRun(keyPath)
or isNeeded(keyPath)
would cleanly separate the main class out, so it's just a coordinator/controller simply running 'steps'
This should also allow for more isomorphic usage patterns - perhaps like this:
var basicGet = Keypather.run.bind([require('./plugins/dottedPaths'), require('./plugins/expandPath')])
var getArray = Keypather.run.bind([require('./plugins/dottedPaths'), require('./plugins/arrayPaths'), require('./plugins/expandPath')])
from keypather.
published [email protected] !
from keypather.
Related Issues (15)
- flatten typeof val === 'object' check unsafe HOT 1
- Undefined values vs undefined properties HOT 4
- bug: keypath.flatten removes empty nested objects
- ES6 import support HOT 2
- Expanding array HOT 3
- Does not create sub-objects properly on set HOT 3
- An in-range update of debug is breaking the build 🚨 HOT 1
- Library does not support Json Keys with characters '-' HOT 1
- feature request: add immutable methods HOT 1
- Flatten function filters out empty arrays.
- 🚨 Potential Security Vulnerability - huntr.dev HOT 2
- Error: Unexpected token '/' in keypath 'channels.smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.publish.message.payload' at position 23 (invalid dot key) HOT 3
- Boast about not using eval :) HOT 1
- Accept an array HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keypather.