Comparing version 3.1.2 to 3.1.3
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="3.1.3"></a> | ||
## [3.1.3](https://github.com/zerkalica/lom_atom/compare/v3.1.2...v3.1.3) (2018-02-02) | ||
<a name="3.1.2"></a> | ||
@@ -7,0 +12,0 @@ ## [3.1.2](https://github.com/zerkalica/lom_atom/compare/v3.1.1...v3.1.2) (2017-12-25) |
@@ -257,5 +257,2 @@ var actionId = Symbol('lom_action'); | ||
var _class; | ||
var _temp; | ||
function checkSlave(slave) { | ||
@@ -280,3 +277,4 @@ slave.check(); | ||
var proxyId = Symbol('lom_err_proxy'); | ||
var Atom = (_temp = _class = | ||
var Atom = | ||
/*#__PURE__*/ | ||
@@ -544,4 +542,6 @@ function () { | ||
return Atom; | ||
}(), _class.deepReset = undefined, _temp); | ||
}(); | ||
Atom.deepReset = undefined; | ||
function createAction(fn, sync) { | ||
@@ -548,0 +548,0 @@ return createActionMethod({ |
@@ -261,5 +261,2 @@ 'use strict'; | ||
var _class; | ||
var _temp; | ||
function checkSlave(slave) { | ||
@@ -284,3 +281,4 @@ slave.check(); | ||
var proxyId = Symbol('lom_err_proxy'); | ||
var Atom = (_temp = _class = | ||
var Atom = | ||
/*#__PURE__*/ | ||
@@ -548,4 +546,6 @@ function () { | ||
return Atom; | ||
}(), _class.deepReset = undefined, _temp); | ||
}(); | ||
Atom.deepReset = undefined; | ||
function createAction(fn, sync) { | ||
@@ -552,0 +552,0 @@ return createActionMethod({ |
@@ -263,5 +263,2 @@ (function (global, factory) { | ||
var _class; | ||
var _temp; | ||
function checkSlave(slave) { | ||
@@ -286,3 +283,4 @@ slave.check(); | ||
var proxyId = Symbol('lom_err_proxy'); | ||
var Atom = (_temp = _class = | ||
var Atom = | ||
/*#__PURE__*/ | ||
@@ -550,4 +548,6 @@ function () { | ||
return Atom; | ||
}(), _class.deepReset = undefined, _temp); | ||
}(); | ||
Atom.deepReset = undefined; | ||
function createAction(fn, sync) { | ||
@@ -554,0 +554,0 @@ return createActionMethod({ |
{ | ||
"name": "lom_atom", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"description": "Alternative implementation of eigenmethod mol_atom state management library", | ||
@@ -54,19 +54,20 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@babel/core": "=7.0.0-beta.34", | ||
"@babel/plugin-external-helpers": "=7.0.0-beta.34", | ||
"@babel/plugin-proposal-class-properties": "=7.0.0-beta.34", | ||
"@babel/plugin-proposal-decorators": "=7.0.0-beta.34", | ||
"@babel/plugin-transform-flow-strip-types": "=7.0.0-beta.34", | ||
"@babel/preset-es2015": "=7.0.0-beta.34", | ||
"@babel/register": "=7.0.0-beta.34", | ||
"@babel/core": "=7.0.0-beta.39", | ||
"@babel/plugin-external-helpers": "=7.0.0-beta.39", | ||
"@babel/plugin-proposal-class-properties": "=7.0.0-beta.39", | ||
"@babel/plugin-proposal-decorators": "=7.0.0-beta.39", | ||
"@babel/plugin-transform-flow-strip-types": "=7.0.0-beta.39", | ||
"@babel/preset-es2015": "=7.0.0-beta.39", | ||
"@babel/register": "=7.0.0-beta.39", | ||
"@babel/plugin-check-constants": "^7.0.0-beta.38", | ||
"chokidar-cli": "^1.2.0", | ||
"flow-bin": "^0.61.0", | ||
"mocha": "^4.0.1", | ||
"flow-bin": "^0.64.0", | ||
"mocha": "^5.0.0", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.53.0", | ||
"rollup": "^0.55.3", | ||
"rollup-plugin-babel": "^4.0.0-beta.0", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"standard-version": "^4.2.0", | ||
"uglify-es": "^3.3.1" | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"standard-version": "^4.3.0", | ||
"uglify-es": "^3.3.9" | ||
} | ||
} |
@@ -61,5 +61,27 @@ /* @flow */ | ||
getId(t: T): Id { | ||
return (t: any) | ||
return (JSON.stringify(t): any) | ||
} | ||
copy(raw: T[] | Collection<T, Id>): Collection<T, Id> { | ||
const {_indices: indices, _items: items} = this | ||
let isNewElements = false | ||
const newItems: T[] = [] | ||
const newIndices: Map<Id, number> = new Map() | ||
const next: T[] = raw instanceof Collection ? raw._items : raw | ||
for (let i = 0, l = next.length; i < l; i++) { | ||
let newItem = next[i] | ||
const id = this.getId(newItem) | ||
const index = indices.get(id) | ||
if (index !== i) isNewElements = true | ||
newIndices.set(id, i) | ||
newItems.push(index === undefined ? newItem : items[index]) | ||
} | ||
if (!isNewElements) return this | ||
const copy = new this.constructor(newItems, newIndices, this._parent) | ||
this._parent.notify(copy) | ||
return copy | ||
} | ||
_notify(): Collection<T, Id> { | ||
@@ -91,3 +113,3 @@ // const copy = Object.assign(Object.create(this.constructor.prototype), (this: Object)) | ||
set(item: T | ((item: T) => T | void)): Collection<T, Id> { | ||
const {_indices: indices, _items: items} = this | ||
const {_items: items} = this | ||
let isUpdated = false | ||
@@ -104,2 +126,3 @@ if (typeof item === 'function') { | ||
} else { | ||
const indices = this._indices | ||
const id = this.getId(item) | ||
@@ -120,3 +143,4 @@ const index = indices.get(id) | ||
delete(cb: T | ((item: T) => boolean)): Collection<T, Id> { | ||
const {_indices: indices, _items: items} = this | ||
const {_items: items} = this | ||
const indices = this._indices | ||
let isUpdated = false | ||
@@ -123,0 +147,0 @@ if (typeof cb === 'function') { |
@@ -42,3 +42,3 @@ // @flow | ||
export const scheduleNative: (handler: () => void) => number = typeof requestAnimationFrame === 'function' | ||
export const scheduleNative: (handler: () => void) => mixed = typeof requestAnimationFrame === 'function' | ||
? (handler: () => void) => requestAnimationFrame(handler) | ||
@@ -45,0 +45,0 @@ : (handler: () => void) => setTimeout(handler, 16) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
290084
3577
17