Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "stx", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "a blazing fast state manager with network sync out of the box", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
101
src/index.js
@@ -1,13 +0,6 @@ | ||
import { getString } from './cache' | ||
import { root } from './id' | ||
import { getFromLeaves, getByKey, getApi } from './get' | ||
import { set } from './manipulate' | ||
import { origin, compute, inspect, serialize } from './fn' | ||
import { forEach } from './iteration' | ||
import { defineApi, set } from './api/index' | ||
const define = (obj, key, val) => { | ||
Object.defineProperty(obj, key, { value: val, configurable: true }) | ||
} | ||
const Leaf = function (val, stamp, id, branch, parent, key) { | ||
this.id = id | ||
if (parent) { | ||
@@ -25,52 +18,2 @@ this.p = parent | ||
const leaf = Leaf.prototype | ||
define(leaf, 'set', function (val, stamp) { | ||
set(this, val, stamp, this.id, this.branch) | ||
}) | ||
define(leaf, 'get', function (path, val, stamp) { | ||
return getApi(this.branch, path, this.id, val, stamp) | ||
}) | ||
define(leaf, 'origin', function () { | ||
return origin(this.branch, this) | ||
}) | ||
define(leaf, 'compute', function () { | ||
return compute(this.branch, this) | ||
}) | ||
define(leaf, 'parent', function () { | ||
return getFromLeaves(this.branch, this.p) | ||
}) | ||
define(leaf, 'root', function () { | ||
return this.branch.leaves[root] | ||
}) | ||
define(leaf, 'inspect', function () { | ||
return inspect(this.branch, this) | ||
}) | ||
define(leaf, 'serialize', function () { | ||
return serialize(this.branch, this) | ||
}) | ||
define(leaf, 'path', function () { | ||
let parent = this | ||
const path = [] | ||
while (parent && parent.id !== root) { | ||
path.unshift(getString(parent.key)) | ||
parent = getFromLeaves(this.branch, parent.p) | ||
} | ||
return path | ||
}) | ||
define(leaf, 'forEach', function (cb) { | ||
return forEach(this.branch, this, cb) | ||
}) | ||
define(leaf, 'isLeaf', true) | ||
const Struct = function (val, stamp, inherits) { | ||
@@ -87,40 +30,4 @@ this.leaves = {} | ||
const struct = Struct.prototype | ||
defineApi(Leaf.prototype, Struct.prototype) | ||
define(struct, 'create', function (val, stamp) { | ||
return new Struct(val, stamp, this) | ||
}) | ||
define(struct, 'set', function (val, stamp) { | ||
set(this.leaves[root], val, stamp, root, this) | ||
}) | ||
define(struct, 'get', function (path, val, stamp) { | ||
return getApi(this, path, root, val, stamp) | ||
}) | ||
define(struct, 'parent', function () { | ||
return void 0 | ||
}) | ||
define(struct, 'root', function () { | ||
return this.leaves[root] | ||
}) | ||
define(struct, 'inspect', function () { | ||
return inspect(this, this.leaves[root]) | ||
}) | ||
define(struct, 'serialize', function () { | ||
return serialize(this, this.leaves[root]) | ||
}) | ||
define(struct, 'path', function () { | ||
return [] | ||
}) | ||
define(struct, 'forEach', function (cb) { | ||
return forEach(this, this.leaves[root], cb) | ||
}) | ||
export { Leaf, Struct, getByKey, getApi } | ||
export { Leaf, Struct } |
require('./set-get') | ||
require('./path-collusion') | ||
require('./branch') | ||
require('./reference') | ||
require('./array-api') |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
26953
17
971
1