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

0.0.7 • Public • Published

gsw

get, set, watch

github npm:version typescript ci:status Coverage Status document:typedoc license browserslist code style: prettier

Usage

/**
 * To prepare of using the `gsw`
 * ```sh
 * yarn add gsw
 * ```
 */
import gsw from 'gsw';

or

<script src="https://unpkg.com/gsw/gsw.js"></script>
<script>
  // Can use the `gsw` here.
</script> 

Example

const value = gsw({
  foo: 'str',
  bar: 123,
  baz: true
});
 
// get
expect(value('foo')).toBe('str');
 
// set
value('bar', 456);
expect(value('bar')).toBe(456);
 
// listener
value('baz', (newValue, oldValue) => {
  console.log(`newValue: ${newValue}, oldValue: ${oldValue}`);
});
value('baz', false);
// newValue: false, oldValue: true
value('baz', false);
value('baz', true);
// newValue: true, oldValue: false

Edit @gsw/example

Readme

Keywords

Package Sidebar

Install

npm i gsw

Weekly Downloads

7

Version

0.0.7

License

MIT

Unpacked Size

11.4 kB

Total Files

14

Last publish

Collaborators

  • nju33