Comparing version 0.0.0 to 0.0.1
@@ -1,2 +0,2 @@ | ||
module.exports=function(t){function e(r){if(n[r])return n[r].exports;var u=n[r]={exports:{},id:r,loaded:!1};return t[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";n(!function(){var t=new Error('Cannot find module "sproute-data"');throw t.code="MODULE_NOT_FOUND",t}());t.exports=function(t,e){this._value=t,this._parent=e},Foliage.prototype={get:function(t,e){return sprout.get(this._value,t,e)},set:function(t,e){this._value=sprout.assoc(this._value,t,e)},branch:function(t,e){return new Foliage(this.get(t,e),this)},trunk:function(){return this._parent?this._parent.trunk():this},keys:function(){return Object.keys(this._value)},values:function(){var t=this;return this.keys().map(function(e){return t.get(e)},this)},map:function(t,e){return this.values().map(t,e)},filter:function(t){return this.values().filter(t)},find:function(t){return this.filter(t)[0]},reduce:function(t,e,n){return this.values().reduce(t,e,n)},value:function(){return this.valueOf()},valueOf:function(){return this._value},is:function(t){return this.valueOf()===t.valueOf()}}}]); | ||
module.exports=function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t["default"]:t},o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},u=r(1),i=n(u),s=function(){function t(e,r){o(this,t),this._value=e,this._parent=r}return t.prototype.get=function(t,e){return i.get(this._value,t,e)},t.prototype.set=function(t,e){this._value=i.assoc(this._value,t,e)},t.prototype.branch=function(e,r){return new t(this.get(e,r),this)},t.prototype.trunk=function(){return this._parent?this._parent.trunk():this},t.prototype.keys=function(){return Object.keys(this._value)},t.prototype.values=function(){var t=this;return this.keys().map(function(e){return t.get(e)},this)},t.prototype.map=function(t,e){return this.values().map(t,e)},t.prototype.filter=function(t){return this.values().filter(t)},t.prototype.find=function(t){return this.filter(t)[0]},t.prototype.reduce=function(t,e,r){return this.values().reduce(t,e,r)},t.prototype.value=function(){return this.valueOf()},t.prototype.valueOf=function(){return this._value},t.prototype.is=function(t){return this.valueOf()===t.valueOf()},t}();t.exports=s},function(t){t.exports=require("sprout-data")}]); | ||
//# sourceMappingURL=Foliage.js.map |
{ | ||
"name": "foliage", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "A cursor like tree data structure on top of sprout.", | ||
@@ -5,0 +5,0 @@ "main": "dist/Foliage.js", |
@@ -5,58 +5,58 @@ /** | ||
let sproute = require('sproute-data') | ||
import sprout from 'sprout-data' | ||
module.exports = function Foliage(value, parent) { | ||
this._value = value | ||
this._parent = parent | ||
} | ||
export default class Foliage { | ||
Foliage.prototype = { | ||
constructor(value, parent) { | ||
this._value = value | ||
this._parent = parent | ||
} | ||
get(key, fallback) { | ||
return sprout.get(this._value, key, fallback) | ||
}, | ||
} | ||
set(key, value) { | ||
this._value = sprout.assoc(this._value, key, value) | ||
}, | ||
} | ||
branch(key, fallback) { | ||
return new Foliage(this.get(key, fallback), this) | ||
}, | ||
} | ||
trunk() { | ||
return this._parent ? this._parent.trunk() : this | ||
}, | ||
} | ||
keys() { | ||
return Object.keys(this._value) | ||
}, | ||
} | ||
values() { | ||
return this.keys().map(key => this.get(key), this) | ||
}, | ||
} | ||
map(fn, scope) { | ||
return this.values().map(fn, scope) | ||
}, | ||
} | ||
filter(fn) { | ||
return this.values().filter(fn) | ||
}, | ||
} | ||
find(fn) { | ||
return this.filter(fn)[0] | ||
}, | ||
} | ||
reduce(fn, initial, scope) { | ||
return this.values().reduce(fn, initial, scope) | ||
}, | ||
} | ||
value() { | ||
return this.valueOf() | ||
}, | ||
} | ||
valueOf() { | ||
return this._value | ||
}, | ||
} | ||
@@ -63,0 +63,0 @@ is(branch) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20927
238
3