@insertish/mutable
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -20,2 +20,3 @@ import { Collection } from '@insertish/zangodb'; | ||
set(state: T): void; | ||
setOverride(state: T): void; | ||
patch(id: string, state: Partial<T>): void; | ||
@@ -22,0 +23,0 @@ delete(_id: string): void; |
@@ -71,2 +71,17 @@ "use strict"; | ||
} | ||
setOverride(state) { | ||
var _a; | ||
let existing = this.getMutable(state._id); | ||
if (existing) { | ||
this.map[state._id] = new Proxy(state, this.proxyHandler); | ||
this.emit('update', state._id); | ||
(_a = this.collection) === null || _a === void 0 ? void 0 : _a.update({ _id: state._id }, { | ||
$unset: Object.keys(existing).filter(x => x !== '_id'), | ||
$set: Object.assign({}, state) | ||
}); | ||
} | ||
else { | ||
this.create(state); | ||
} | ||
} | ||
patch(id, state) { | ||
@@ -73,0 +88,0 @@ let item = this.map[id]; |
{ | ||
"name": "@insertish/mutable", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Mutable object utilities.", | ||
@@ -28,3 +28,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@insertish/zangodb": "1.0.11", | ||
"@insertish/zangodb": "^1.0.12", | ||
"eventemitter3": "^4.0.7", | ||
@@ -31,0 +31,0 @@ "lodash.isequal": "^4.5.0" |
@@ -0,1 +1,3 @@ | ||
![npm](https://img.shields.io/npm/v/@insertish/mutable?style=flat-square) | ||
### Why? | ||
@@ -18,3 +20,3 @@ | ||
```typescript | ||
import { MutableMap } from 'mutable.js'; | ||
import { MutableMap } from '@insertish/mutable'; | ||
@@ -21,0 +23,0 @@ type User = { |
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
17334
184
72
+ Added@insertish/zangodb@1.0.12(transitive)
- Removed@insertish/zangodb@1.0.11(transitive)
Updated@insertish/zangodb@^1.0.12