Skip to content

Commit

Permalink
v4.0.0
Browse files Browse the repository at this point in the history
Major API change. Removed GawkObject and GawkArray. Significantly simplified the code. Now plays nice with object instances.

Removed CodeClimate since it doesn't offer enough value.
  • Loading branch information
cb1kenobi committed Apr 8, 2017
1 parent 00330e8 commit 9663cb9
Show file tree
Hide file tree
Showing 12 changed files with 1,289 additions and 1,389 deletions.
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"plugins": ["transform-es2015-modules-commonjs"]
"plugins": [
"transform-class-properties",
"transform-es2015-modules-commonjs"
]
}
16 changes: 0 additions & 16 deletions .codeclimate.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"no-cond-assign": 0,
"no-unused-vars": 0,
"constructor-super": 0,
"no-class-assign": 0
"no-class-assign": 0,
"no-debugger": 0
}
}
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ sudo: false
install: npm install -g yarn && yarn
before_script: sh -c "git log | head -12"
script: npm run coverage
after_success:
- coveralls < ./coverage/lcov.info
- CODECLIMATE_REPO_TOKEN=fb038884df12a473bb3cc13c8ef5323227e19c8818327926cde26e89eb7f31cb codeclimate-test-reporter < ./coverage/lcov.info
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016 Chris Barber
Copyright (c) 2016-2017 Chris Barber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
52 changes: 29 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
[![NPM Downloads][downloads-image]][downloads-url]
[![Travis CI Build][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Code Climate][codeclimate-image]][codeclimate-url]
[![Deps][david-image]][david-url]
[![Dev Deps][david-dev-image]][david-dev-url]

Gawk wraps JavaScript objects and arrays making them observable. Once a
JavaScript value is gawked, you can listen for changes including deeply nested
changes. Only objects and arrays can be gawked. All other types are passed
through.
Gawk wraps JavaScript objects and arrays making them observable. Once a JavaScript object is gawked,
you can listen for changes including deeply nested changes. Only objects and arrays can be gawked.
All other types are passed through.

Gawked objects and arrays can be interacted with as if they were regular
objects/arrays. Built-in functions such as `JSON.stringify()` work as expected.
Gawked objects and arrays can be interacted with as if they were regular objects/arrays. Built-in
functions such as `JSON.stringify()` work as expected.

> Note: gawk uses ES2015 proxies and thus requires Node.js 6 or newer.
Expand Down Expand Up @@ -77,34 +75,44 @@ gawk.watch(obj, [ 'foo', 'bar' ], value => {
obj.foo.bar = 'world!';
```

You can directly create `GawkObject` and `GawkArray` objects:
To stop watching, simply call `gawk.unwatch()` with the original listener function.

```javascript
import { GawkArray, GawkObject } from 'gawk';
const obj = gawk({ /* ... */ });

const obj = new GawkObject({ foo: 'bar' });
const arr = new GawkArray('a', 'b', 'c');
function onChange(obj, src) {
console.log('changed!');
}

gawk.watch(obj, onChange);

obj.foo = 'bar';

gawk.unwatch(obj, onChange);

obj.foo = 'baz'; // does not fire onChange()
```

## Upgrading to v3
## Upgrading to v4

Gawk v4 has dropped all gawk data types. You must always call `gawk()`.

Gawk v3 has dropped all gawk data types except `GawkArray` and `GawkObject`.
Change all `new GawkObject()` calls to `gawk({})` and `new GawkArray()` to `gawk([])`.

Since Gawk v3 uses ES6 Proxies, you no longer need to call `obj.get()`,
`obj.set()`, `obj.delete()`, etc.
Since Gawk v3 and newer uses ES6 Proxies, you no longer need to call `obj.get()`, `obj.set()`,
`obj.delete()`, etc.

Methods `obj.watch()`, `obj.merge()`, and `obj.mergeDeep()` have moved to
`gawk.watch()`, `gawk.merge()`, and `gawk.mergeDeep()`. The first argument must
be a gawk object.
Methods `obj.watch()`, `obj.merge()`, and `obj.mergeDeep()` have moved to `gawk.watch()`,
`gawk.merge()`, and `gawk.mergeDeep()`. The first argument must be a gawk object.

Gawk v3 no longer hashes values. This means speed. Gawk v3 is about 19 times
faster than v1 and v2.
Starting in v3, Gawk no longer hashes values. This means speed. Gawk v3+ is about 19 times faster
than v1 and v2.

## License

(The MIT License)

Copyright (c) 2016 Chris Barber
Copyright (c) 2016-2017 Chris Barber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -132,8 +140,6 @@ THE SOFTWARE.
[travis-url]: https://travis-ci.org/cb1kenobi/gawk
[coveralls-image]: https://img.shields.io/coveralls/cb1kenobi/gawk/master.svg
[coveralls-url]: https://coveralls.io/r/cb1kenobi/gawk
[codeclimate-image]: https://img.shields.io/codeclimate/github/cb1kenobi/gawk.svg
[codeclimate-url]: https://codeclimate.com/github/cb1kenobi/gawk
[david-image]: https://img.shields.io/david/cb1kenobi/gawk.svg
[david-url]: https://david-dm.org/cb1kenobi/gawk
[david-dev-image]: https://img.shields.io/david/dev/cb1kenobi/gawk.svg
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gawk",
"version": "3.4.0",
"version": "4.0.0",
"description": "Observable JavaScript object model",
"main": "./dist/index.js",
"author": "Chris Barber <[email protected]> (https://github.com/cb1kenobi)",
Expand All @@ -27,10 +27,10 @@
},
"devDependencies": {
"babel-eslint": "^7.2.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"chai": "^3.5.0",
"codeclimate-test-reporter": "^0.4.1",
"coveralls": "^2.12.0",
"coveralls": "^2.13.0",
"del": "^2.2.2",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
Expand All @@ -44,7 +44,7 @@
"gulp-load-plugins": "^1.5.0",
"gulp-mocha": "^3.0.1",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.4.1",
"gulp-sourcemaps": "^2.5.1",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0"
},
Expand Down
Loading

0 comments on commit 9663cb9

Please sign in to comment.