detto
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

detto

npm version CI Coverage Status gzip visitors

Demo

Track old values for object

Track old values for array

Feature

You can save anything in detto object even the values is changed or moved (by array manipulation functions).

Array Manipulations (push, pop, shift, unshift, splice, reverse) is Fully Supported.

Zero Dependencies, Native Javascript only.

Installation

$ yarn add detto
<script src="https://unpkg.com/detto"></script>

Usage

import { proxy } from 'Detto'
 
const object = {
  deep: {
    nested: 123,
  },
}
 
const detto = {}
 
// watch data changing
const callback = (changedDetto, path) => console.log(path)
 
const proxiedObject = proxy({ object, detto, callback })
// > []
// > ['deep']
// > ['deep', 'nested']
console.log(JSON.stringify(detto))
// > {"deep":{"nested":{}}}
 
proxiedObject.deep.nested = { key: 123 }
// > ['deep', 'nested']
// > ['deep', 'nested', 'key']
console.log(JSON.stringify(detto))
// > {"deep":{"nested":{"key":{}}}}
 
proxiedObject.deep.nested = {}
// > ['deep', 'nested']
console.log(JSON.stringify(detto))
// > {"deep":{"nested":{}}}
 
delete proxiedObject.deep
// > []
console.log(JSON.stringify(detto))
// > {}

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details

Readme

Keywords

Package Sidebar

Install

npm i detto

Weekly Downloads

11

Version

1.1.1

License

MIT

Unpacked Size

193 kB

Total Files

44

Last publish

Collaborators

  • iendeavor