[
  {
    "path": ".eslintrc",
    "content": "{\n    \"parser\": \"babel-eslint\",\n\n    \"env\": {\n        \"browser\": true,\n        \"node\": true,\n        \"es6\": true\n    },\n\n    \"ecmaFeatures\": {\n        \"jsx\": true,\n        \"superInFunctions\": false,\n        \"classes\": false,\n        \"modules\": [2]\n    },\n\n    \"rules\": {\n        \"block-scoped-var\": [0],\n        \"brace-style\": [2, \"1tbs\", { \"allowSingleLine\": true }],\n        \"camelcase\": [0],\n        \"comma-dangle\": [2, \"never\"],\n        \"comma-spacing\": [2],\n        \"comma-style\": [2, \"last\"],\n        \"complexity\": [0, 11],\n        \"consistent-return\": [2],\n        \"consistent-this\": [0, \"that\"],\n        \"curly\": [2, \"multi-line\"],\n        \"default-case\": [2],\n        \"dot-notation\": [2, { \"allowKeywords\": true }],\n        \"eol-last\": [2],\n        \"eqeqeq\": [2],\n        \"func-names\": [0],\n        \"func-style\": [0, \"declaration\"],\n        \"generator-star-spacing\": [2, \"after\"],\n        \"global-strict\": [2, \"always\"],\n        \"guard-for-in\": [0],\n        \"handle-callback-err\": [0],\n        \"key-spacing\": [2, { \"beforeColon\": false, \"afterColon\": true }],\n        \"quotes\": [2, \"single\", \"avoid-escape\"],\n        \"max-depth\": [0, 4],\n        \"max-len\": [0, 80, 4],\n        \"max-nested-callbacks\": [0, 2],\n        \"max-params\": [0, 3],\n        \"max-statements\": [0, 10],\n        \"new-parens\": [2],\n        \"new-cap\": [0],\n        \"newline-after-var\": [0],\n        \"no-alert\": [2],\n        \"no-array-constructor\": [2],\n        \"no-bitwise\": [0],\n        \"no-caller\": [2],\n        \"no-catch-shadow\": [2],\n        \"no-cond-assign\": [2],\n        \"no-console\": [0],\n        \"no-constant-condition\": [1],\n        \"no-continue\": [2],\n        \"no-control-regex\": [2],\n        \"no-debugger\": [2],\n        \"no-delete-var\": [2],\n        \"no-div-regex\": [0],\n        \"no-dupe-args\": [2],\n        \"no-dupe-keys\": [2],\n        \"no-duplicate-case\": [2],\n        \"no-else-return\": [0],\n        \"no-empty\": [2],\n        \"no-empty-class\": [2],\n        \"no-empty-label\": [2],\n        \"no-eq-null\": [0],\n        \"no-eval\": [2],\n        \"no-ex-assign\": [2],\n        \"no-extend-native\": [1],\n        \"no-extra-bind\": [2],\n        \"no-extra-boolean-cast\": [2],\n        \"no-extra-parens\": [0],\n        \"no-extra-semi\": [1],\n        \"no-extra-strict\": [2],\n        \"no-fallthrough\": [2],\n        \"no-floating-decimal\": [2],\n        \"no-func-assign\": [2],\n        \"no-implied-eval\": [2],\n        \"no-inline-comments\": [0],\n        \"no-inner-declarations\": [2, \"functions\"],\n        \"no-invalid-regexp\": [2],\n        \"no-irregular-whitespace\": [2],\n        \"no-iterator\": [2],\n        \"no-label-var\": [2],\n        \"no-labels\": [2],\n        \"no-lone-blocks\": [2],\n        \"no-lonely-if\": [2],\n        \"no-loop-func\": [2],\n        \"no-mixed-requires\": [0, false],\n        \"no-mixed-spaces-and-tabs\": [2, false],\n        \"no-multi-spaces\": [2],\n        \"no-multi-str\": [2],\n        \"no-multiple-empty-lines\": [2, { \"max\": 2 }],\n        \"no-native-reassign\": [1],\n        \"no-negated-in-lhs\": [2],\n        \"no-nested-ternary\": [0],\n        \"no-new\": [2],\n        \"no-new-func\": [2],\n        \"no-new-object\": [2],\n        \"no-new-require\": [0],\n        \"no-new-wrappers\": [2],\n        \"no-obj-calls\": [2],\n        \"no-octal\": [2],\n        \"no-octal-escape\": [2],\n        \"no-param-reassign\": [2],\n        \"no-path-concat\": [0],\n        \"no-plusplus\": [0],\n        \"no-process-env\": [0],\n        \"no-process-exit\": [2],\n        \"no-proto\": [2],\n        \"no-redeclare\": [2],\n        \"no-regex-spaces\": [2],\n        \"no-reserved-keys\": [0],\n        \"no-restricted-modules\": [0],\n        \"no-return-assign\": [2],\n        \"no-script-url\": [2],\n        \"no-self-compare\": [0],\n        \"no-sequences\": [2],\n        \"no-shadow\": [2],\n        \"no-shadow-restricted-names\": [2],\n        \"no-space-before-semi\": [2],\n        \"no-spaced-func\": [2],\n        \"no-sparse-arrays\": [2],\n        \"no-sync\": [0],\n        \"no-ternary\": [0],\n        \"no-throw-literal\": [2],\n        \"no-trailing-spaces\": [2],\n        \"no-undef\": [2],\n        \"no-undef-init\": [2],\n        \"no-undefined\": [0],\n        \"no-underscore-dangle\": [2],\n        \"no-unreachable\": [2],\n        \"no-unused-expressions\": [2],\n        \"no-unused-vars\": [1, { \"vars\": \"all\", \"args\": \"after-used\" }],\n        \"no-use-before-define\": [2],\n        \"no-void\": [0],\n        \"no-warning-comments\": [0, { \"terms\": [\"todo\", \"fixme\", \"xxx\"], \"location\": \"start\" }],\n        \"no-with\": [2],\n        \"no-wrap-func\": [2],\n        \"one-var\": [0],\n        \"operator-assignment\": [0, \"always\"],\n        \"operator-linebreak\": [2, \"after\"],\n        \"padded-blocks\": [0],\n        \"quote-props\": [0],\n        \"radix\": [0],\n        \"semi\": [2],\n        \"semi-spacing\": [2, { \"before\": false, \"after\": true }],\n        \"sort-vars\": [0],\n        \"space-after-keywords\": [2, \"always\"],\n        \"space-before-function-paren\": [2, { \"anonymous\": \"always\", \"named\": \"always\" }],\n        \"space-before-blocks\": [0, \"always\"],\n        \"space-in-brackets\": [0, \"never\", {\n            \"singleValue\": true,\n            \"arraysInArrays\": false,\n            \"arraysInObjects\": false,\n            \"objectsInArrays\": true,\n            \"objectsInObjects\": true,\n            \"propertyName\": false\n        }],\n        \"space-in-parens\": [2, \"never\"],\n        \"space-infix-ops\": [2],\n        \"space-return-throw-case\": [2],\n        \"space-unary-ops\": [2, { \"words\": true, \"nonwords\": false }],\n        \"spaced-line-comment\": [0, \"always\"],\n        \"strict\": [1],\n        \"use-isnan\": [2],\n        \"valid-jsdoc\": [0],\n        \"valid-typeof\": [2],\n        \"vars-on-top\": [0],\n        \"wrap-iife\": [2],\n        \"wrap-regex\": [2],\n        \"yoda\": [2, \"never\", { \"exceptRange\": true }]\n    }\n}"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n.validate.json\n.jshintrc\n.jshintignore"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n  - \"0.12\"\n  - \"0.11\"\n  - \"0.10\"\n  - \"iojs\"\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Eric Elliott\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "README.md",
    "content": "# irecord [![Build Status](https://travis-ci.org/ericelliott/irecord.svg?branch=master)](https://travis-ci.org/ericelliott/irecord)\n\nAn immutable object map that exposes an RxJS observable.\n\n\nWritten for the [Learn JavaScript with Eric Elliott](https://ericelliottjs.com/) online JavaScript course series.\n\n\n## Status - DEPRECATED - try [lenses](https://medium.com/javascript-scene/lenses-b85976cb0534) or [transducers](https://medium.com/javascript-scene/transducers-efficient-data-processing-pipelines-in-javascript-7985330fe73d) instead.\n\nThis project was an experiment and is no longer under active development.\n\n\n## Wait, what is this thing?\n\nImagine a JavaScript object that just stores data. Now imagine that every time you change that object, the object emits a change event. Yeah, kindof like Backbone models, but different.\n\n\n## What is reactive programming?\n\nThe concept of reactive programming, and more specifically, how it differs from event listeners and the observer pattern is sometimes hard for beginners. [Resources that might help](./reactive-programming.md).\n\n### How is it different?\n\nWhen you change the value of a key, the previous value doesn't get erased. Instead, it gets added to a history. Every time you make a change, the new object state and the previous object state get emitted with the change event.\n\nIn other words, you can very easily compare the two objects if you need to see what changed. In fact, if you set a property to the same value as the previous value, no change event gets emitted at all.\n\n\n### What's this RxJS thing?\n\nInstead of subscribing to change events with `.on()`, you could use the RxJS `.subscribe()` method. Maybe later we'll add lots of other neat capabilities that RxJS makes possible.\n\n\n### Why would I want to use this with React?\n\nPretty simple really, it makes it easy for your components to subscribe to changes in your store. Since it's backed by Immutable.js, you only render when something actually changes, which can save React the trouble of building a whole virtual DOM and diffing that against the actual DOM.\n\nWhy even start if you know nothing is different? irecord knows when React doesn't have any work to do so you only run `React.render()` when it does.\n\n\n## Install\n\n```\n$ npm install --save irecord\n```\n\n\n## Use / API\n\n```js\nimport irecord from 'irecord';\n\n\nconst record = irecord({\n  a: 'a',\n  b: 'b'\n});\n\n// record.get('a') // => 'a'\n  assert.equal(record.get('a'), 'a',\n    '.get() should return a value for the specified key.');\n\n\n\nrecord.set('c', 'c');\n\n  assert.equal(record.get('c'), 'c',\n    '.set() should set the value for the specified key');\n\n\n\nrecord.remove('b');\n\n  assert.equal(record.get('b'), undefined,\n    '.remove() should remove the key passed in');\n\n\n// record.toJS(); // => [Object object]\n//   get record as regular JS object.\nconst obj2 = record.toJS();\n\n  assert.deepEqual(record, obj2,\n    '.toJS() should return a JS object');\n```\n\n\n## Events\n\n```js\nconst original = {\n  a: 'a',\n  b: 'b'\n};\nconst record = irecord(original);\n\n// Listen for change events - get current and previous values.\nrecord.on('change', ({ value, previous }) => {\n  assert.pass('should emit change events.');\n\n  assert.deepEqual(value.toJS(), {\n    a: 'a',\n    b: 'b',\n    c: 'c'\n  }, 'new value should be passed.');\n\n  assert.deepEqual(previous.toJS(), original,\n    'previous value should be passed.');\n});\n\nrecord.set('c', 'c');\n```\n\n\n## Rx Observable\n\nHere are the Rx Observable methods you can use with irecord instances.\n\n### .subscribe()\n\n```\nrecord.subscribe(\n  ({ value, previous }) => {\n    assert.pass('should emit change events.');\n\n    assert.deepEqual(value.toJS(), {\n      a: 'a',\n      b: 'b',\n      c: 'c'\n    }, 'new value should be passed.');\n\n    assert.deepEqual(previous.toJS(), original,\n      'previous value should be passed.');\n\n  },\n  (err) => { assert.fail('err: ' + err); },\n  () => { assert.pass('complete'); }\n);\n```\n\n\n### .filter()\n\n```js\nconst original = {\n  a: 'a',\n  b: 'b'\n};\nconst record = irecord(original);\n\nrecord.filter(({value}) => {\n  return value.toJS().c === 'again';\n}).subscribe(({ value }) => {\n  assert.equal(value.toJS().c, 'again',\n    `should filter out changes that don't match the predicate`);\n});\n\nrecord.set('a', 'changed');\nrecord.set('c', 'c');\nrecord.set('c', 'again');\n```\n"
  },
  {
    "path": "build/index.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, '__esModule', {\n  value: true\n});\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _immutable = require('immutable');\n\nvar _immutable2 = _interopRequireDefault(_immutable);\n\nvar _dpath = require('dpath');\n\nvar _dpath2 = _interopRequireDefault(_dpath);\n\nvar _events = require('events');\n\nvar _events2 = _interopRequireDefault(_events);\n\nvar _stampit = require('stampit');\n\nvar _stampit2 = _interopRequireDefault(_stampit);\n\nvar _rx = require('rx');\n\nvar _rx2 = _interopRequireDefault(_rx);\n\nvar irecord = function irecord(obj) {\n  var stamp = undefined,\n      instance = undefined;\n\n  var history = [];\n\n  var state = function state() {\n    return history[history.length - 1];\n  };\n\n  var update = function update(value) {\n    if (state() === value) return;\n\n    var previous = state();\n\n    history.push(value);\n    instance.emit('change', { value: value, previous: previous });\n  };\n\n  history.push(_immutable2['default'].fromJS(obj));\n\n  stamp = _stampit2['default'].convertConstructor(_events2['default'].EventEmitter).methods({\n    get: function get(key) {\n      return state().getIn((0, _dpath2['default'])(key));\n    },\n    set: function set(key, val) {\n      update(state().setIn((0, _dpath2['default'])(key), val));\n      return this;\n    },\n    remove: function remove(key) {\n      update(state().removeIn((0, _dpath2['default'])(key)));\n      return this;\n    },\n    toJS: function toJS() {\n      return state().toJS();\n    }\n  }).init(function () {\n    var source = _rx2['default'].Observable.fromEvent(this, 'change', function (ev) {\n      return ev[0];\n    });\n\n    this.subscribe = source.subscribe.bind(source);\n    this.filter = source.filter.bind(source);\n  });\n\n  instance = stamp.create();\n\n  return _stampit2['default'].extend(instance, { stamp: stamp });\n};\n\nexports['default'] = irecord;\nmodule.exports = exports['default'];\n//# sourceMappingURL=index.js.map"
  },
  {
    "path": "build/test/basics.js",
    "content": "'use strict';\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _tape = require('tape');\n\nvar _tape2 = _interopRequireDefault(_tape);\n\nvar _indexJs = require('../index.js');\n\nvar _indexJs2 = _interopRequireDefault(_indexJs);\n\n(0, _tape2['default'])('immutable', function (assert) {\n  var original = {\n    a: 'a',\n    b: 'b'\n  };\n  var record = (0, _indexJs2['default'])(original);\n\n  record.set('c', 'c');\n\n  assert.deepEqual(original, {\n    a: 'a',\n    b: 'b'\n  }, 'should not mutate original object');\n\n  assert.end();\n});\n\n(0, _tape2['default'])('immutable deep Array', function (assert) {\n  var input = {\n    a: [1, 2]\n  };\n\n  var original = {\n    a: [1, 2]\n  };\n\n  var record = (0, _indexJs2['default'])(input);\n\n  input.a.push(3);\n\n  assert.deepEqual(original.a, record.get('a').toJS(), 'should not mutate original deep array');\n\n  assert.end();\n});\n\n(0, _tape2['default'])('change events', function (assert) {\n  assert.plan(3);\n\n  var original = {\n    a: 'a',\n    b: 'b'\n  };\n  var record = (0, _indexJs2['default'])(original);\n\n  record.on('change', function (_ref) {\n    var value = _ref.value;\n    var previous = _ref.previous;\n\n    assert.pass('should emit change events.');\n\n    assert.deepEqual(value.toJS(), {\n      a: 'a',\n      b: 'b',\n      c: 'c'\n    }, 'new value should be passed.');\n\n    assert.deepEqual(previous.toJS(), original, 'previous value should be passed.');\n  });\n\n  record.set('c', 'c');\n});\n\n(0, _tape2['default'])('.get()', function (assert) {\n  var record = (0, _indexJs2['default'])({\n    a: 'a',\n    b: 'b'\n  });\n\n  assert.equal(record.get('a'), 'a', '.get() should return a value for the specified key.');\n\n  assert.end();\n});\n\n(0, _tape2['default'])('.set()', function (assert) {\n  var record = (0, _indexJs2['default'])({\n    a: 'a',\n    b: 'b'\n  });\n\n  record.set('c', 'c');\n\n  assert.equal(record.get('c'), 'c', '.set() should set the value for the specified key');\n\n  assert.end();\n});\n\n(0, _tape2['default'])('.set() & .get() deep', function (assert) {\n  var record = (0, _indexJs2['default'])({});\n  record.set('a.b.c', 'val');\n\n  assert.deepEqual(record.get('a.b.c'), 'val', 'passing \\'a.b.c\\' as the key should set deep in the record.');\n\n  assert.end();\n});\n\n(0, _tape2['default'])('.toJS', function (assert) {\n  var obj = {\n    a: 'a',\n    b: 'b'\n  };\n\n  var record = (0, _indexJs2['default'])(obj);\n\n  var obj2 = record.toJS();\n\n  assert.deepEqual(obj, obj2, '.toJS() should return a JS object');\n\n  assert.end();\n});\n\n(0, _tape2['default'])('.remove()', function (assert) {\n  var record = (0, _indexJs2['default'])({\n    a: 'a',\n    b: 'b'\n  });\n\n  record.remove('b');\n\n  assert.equal(record.get('b'), undefined, '.remove() should remove the key passed in');\n\n  assert.end();\n});"
  },
  {
    "path": "build/test/index.js",
    "content": "'use strict';\n\nrequire('require-all')(__dirname);"
  },
  {
    "path": "build/test/rx.js",
    "content": "'use strict';\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _tape = require('tape');\n\nvar _tape2 = _interopRequireDefault(_tape);\n\nvar _indexJs = require('../index.js');\n\nvar _indexJs2 = _interopRequireDefault(_indexJs);\n\n(0, _tape2['default'])('.subscribe', function (assert) {\n  assert.plan(3);\n\n  var original = {\n    a: 'a',\n    b: 'b'\n  };\n  var record = (0, _indexJs2['default'])(original);\n\n  record.subscribe(function (_ref) {\n    var value = _ref.value;\n    var previous = _ref.previous;\n\n    assert.pass('should emit change events.');\n\n    assert.deepEqual(value.toJS(), {\n      a: 'a',\n      b: 'b',\n      c: 'c'\n    }, 'new value should be passed.');\n\n    assert.deepEqual(previous.toJS(), original, 'previous value should be passed.');\n  }, function (err) {\n    assert.fail('err: ' + err);\n  }, function () {\n    assert.pass('complete');\n  });\n\n  record.set('c', 'c');\n});\n\n(0, _tape2['default'])('.filter', function (assert) {\n  assert.plan(1);\n\n  var original = {\n    a: 'a',\n    b: 'b'\n  };\n  var record = (0, _indexJs2['default'])(original);\n\n  record.filter(function (_ref2) {\n    var value = _ref2.value;\n\n    return value.toJS().c === 'again';\n  }).subscribe(function (_ref3) {\n    var value = _ref3.value;\n\n    assert.equal(value.toJS().c, 'again', 'should filter out changes that don\\'t match the predicate');\n  });\n\n  record.set('a', 'changed');\n  record.set('c', 'c');\n  record.set('c', 'again');\n  assert.end();\n});"
  },
  {
    "path": "build/test/stampit.js",
    "content": "'use strict';\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _stampit = require('stampit');\n\nvar _stampit2 = _interopRequireDefault(_stampit);\n\nvar _tape = require('tape');\n\nvar _tape2 = _interopRequireDefault(_tape);\n\nvar _indexJs = require('../index.js');\n\nvar _indexJs2 = _interopRequireDefault(_indexJs);\n\n(0, _tape2['default'])('stamp composition with irecord', function (assert) {\n  assert.plan(1);\n\n  var record = (0, _indexJs2['default'])({\n    a: 'a',\n    b: 'b'\n  });\n\n  var stamp = (0, _stampit2['default'])({\n    methods: {\n      countProps: function countProps() {\n        return Object.keys(this.toJS()).length;\n      }\n    }\n  });\n\n  var composedRecord = _stampit2['default'].compose(record.stamp, stamp).create();\n\n  assert.equal(composedRecord.countProps(), 2, 'should expose irecord methods');\n});"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"irecord\",\n  \"version\": \"1.1.1\",\n  \"description\": \"An immutable object map that exposes an RxJS observable. Great for React.\",\n  \"main\": \"build/index.js\",\n  \"scripts\": {\n    \"init\": \"rimraf .validate.json && rimraf .jshintrc\",\n    \"clean\": \"rimraf build && mkdir -p build/test\",\n    \"lint\": \"eslint source && eslint test\",\n    \"prebuild\": \"npm run clean\",\n    \"build\": \"babel -d build source -s && babel -d build/test test\",\n    \"test\": \"node build/test/index.js\",\n    \"prepublish\": \"npm run build\",\n    \"validate\": \"npm run lint && npm run build && npm test\",\n    \"validate-dev\": \"npm run lint && npm run build && npm test | faucet\",\n    \"audit\": \"nsp package\",\n    \"missing\": \"dependency-check package.json\",\n    \"extra\": \"dependency-check package.json --extra --ignore\",\n    \"ok\": \"echo 'OK if the dependencies above are all devDependencies.' && echo 'Clean up any unused dependencies.'\",\n    \"deps\": \"npm run missing && npm run extra && npm run ok\",\n    \"precheck\": \"npm run validate\",\n    \"check\": \"npm run audit && npm run deps && npm outdated --depth 0\",\n    \"precommit\": \"pre-commit run\"\n  },\n  \"pre-commit\": [\n    \"check\"\n  ],\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/ericelliott/istore.git\"\n  },\n  \"keywords\": [\n    \"immutable\",\n    \"rxjs\",\n    \"reactive\",\n    \"observable\",\n    \"store\",\n    \"react\",\n    \"flux\"\n  ],\n  \"author\": \"Eric Elliott\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/ericelliott/irecord/issues\"\n  },\n  \"homepage\": \"https://github.com/ericelliott/irecord\",\n  \"devDependencies\": {\n    \"babel\": \"^5.5.7\",\n    \"babel-eslint\": \"^3.1.15\",\n    \"dependency-check\": \"^2.4.0\",\n    \"eslint\": \"^0.22.1\",\n    \"faucet\": \"0.0.1\",\n    \"nsp\": \"^1.0.1\",\n    \"precommit-hook\": \"^2.0.1\",\n    \"require-all\": \"^1.1.0\",\n    \"rimraf\": \"^2.4.0\",\n    \"tape\": \"^4.0.0\"\n  },\n  \"dependencies\": {\n    \"dpath\": \"^1.0.0\",\n    \"immutable\": \"^3.7.3\",\n    \"rx\": \"^2.5.3\",\n    \"stampit\": \"^2.0.3\"\n  }\n}\n"
  },
  {
    "path": "reactive-programming.md",
    "content": "## Learn About Reactive Programming\n\nReactive programming is a programming paradigm oriented around data flows and the propagation of change. In general, reactive programming tools allow you to evaluate data flows as streams and process those streams with functional utilities to filter, map, or manipulate values as they flow through the system.\n\n### Video\n\n* [Asynchronous Programming at Netflix](https://www.youtube.com/watch?v=gawmdhCNy-A) [Jafar Husain](https://twitter.com/jhusain)\n* [What is Reactive Programming?](https://www.youtube.com/watch?v=dwP1TNXE6fc) [Jafar Husain](https://twitter.com/jhusain) explains reactive programming\n* [Immutability: Putting The Dream Machine To Work](https://www.youtube.com/watch?v=SiFwRtCnxv4) by [David Nolen](https://twitter.com/swannodette)\n\n### Reading\n\n* [Introduction to Reactive Programming](https://gist.github.com/staltz/868e7e9bc2a7b8c1f754)\n* [The Dao of Immutability](https://medium.com/javascript-scene/the-dao-of-immutability-9f91a70c88cd) The Way of the Functional Programmer\n* [The General Theory of Reactivity](https://github.com/kriskowal/gtor) What is all this talk about reactive? Functional? Promises? This is the beginning of a reactive programming bible.\n* [Reactive MVC and the Virtual DOM](http://futurice.com/blog/reactive-mvc-and-the-virtual-dom) Great read, even if you're not a React user.\n"
  },
  {
    "path": "source/index.js",
    "content": "'use strict';\n\nimport immutable from 'immutable';\nimport dp from 'dpath';\nimport events from 'events';\nimport stampit from 'stampit';\nimport Rx from 'rx';\n\nconst irecord = function (obj) {\n  let stamp, instance;\n\n  const history = [];\n\n  const state = function () {\n    return history[history.length - 1];\n  };\n\n  const update = function update (value) {\n    if (state() === value) return;\n\n    const previous = state();\n\n    history.push(value);\n    instance.emit('change', {value, previous});\n  };\n\n  history.push(immutable.fromJS(obj));\n\n  stamp =\n    stampit.convertConstructor(events.EventEmitter)\n    .methods({\n      get (key) {\n        return state().getIn(dp(key));\n      },\n      set (key, val) {\n        update(state().setIn(dp(key), val));\n        return this;\n      },\n      remove (key) {\n        update(state().removeIn(dp(key)));\n        return this;\n      },\n      toJS () {\n        return state().toJS();\n      }\n    })\n    .init(function () {\n      const source = Rx.Observable.fromEvent(\n        this, 'change',\n        (ev) => ev[0]);\n\n      this.subscribe = source.subscribe.bind(source);\n      this.filter = source.filter.bind(source);\n    });\n\n  instance = stamp.create();\n\n  return stampit.extend(\n    instance,\n    { stamp }\n  );\n};\n\nexport default irecord;\n"
  },
  {
    "path": "test/basics.js",
    "content": "'use strict';\n\nimport test from 'tape';\nimport irecord from '../index.js';\n\ntest('immutable', (assert) => {\n  const original = {\n    a: 'a',\n    b: 'b'\n  };\n  const record = irecord(original);\n\n  record.set('c', 'c');\n\n  assert.deepEqual(original, {\n    a: 'a',\n    b: 'b'\n  }, 'should not mutate original object');\n\n  assert.end();\n});\n\n\ntest('immutable deep Array', (assert) => {\n  const input = {\n    a: [1, 2]\n  };\n\n  const original = {\n    a: [1, 2]\n  };\n\n  const record = irecord(input);\n\n  input.a.push(3);\n\n  assert.deepEqual(original.a, record.get('a').toJS(),\n    'should not mutate original deep array');\n\n  assert.end();\n});\n\n\ntest('change events', (assert) => {\n  assert.plan(3);\n\n  const original = {\n    a: 'a',\n    b: 'b'\n  };\n  const record = irecord(original);\n\n  record.on('change', ({ value, previous }) => {\n    assert.pass('should emit change events.');\n\n    assert.deepEqual(value.toJS(), {\n      a: 'a',\n      b: 'b',\n      c: 'c'\n    }, 'new value should be passed.');\n\n    assert.deepEqual(previous.toJS(), original,\n      'previous value should be passed.');\n\n  });\n\n  record.set('c', 'c');\n});\n\n\ntest('.get()', (assert) => {\n  const record = irecord({\n    a: 'a',\n    b: 'b'\n  });\n\n  assert.equal(record.get('a'), 'a',\n    '.get() should return a value for the specified key.');\n\n  assert.end();\n});\n\n\ntest('.set()', (assert) => {\n  const record = irecord({\n    a: 'a',\n    b: 'b'\n  });\n\n  record.set('c', 'c');\n\n  assert.equal(record.get('c'), 'c',\n    '.set() should set the value for the specified key');\n\n  assert.end();\n});\n\n\ntest('.set() & .get() deep', assert => {\n  const record = irecord({});\n  record.set('a.b.c', 'val');\n\n  assert.deepEqual(record.get('a.b.c'), 'val',\n    `passing 'a.b.c' as the key should set deep in the record.`);\n\n  assert.end();\n});\n\n\ntest('.toJS', (assert) => {\n  const obj = {\n    a: 'a',\n    b: 'b'\n  };\n\n  const record = irecord(obj);\n\n  const obj2 = record.toJS();\n\n  assert.deepEqual(obj, obj2,\n    '.toJS() should return a JS object');\n\n  assert.end();\n});\n\n\ntest('.remove()', (assert) => {\n  const record = irecord({\n    a: 'a',\n    b: 'b'\n  });\n\n  record.remove('b');\n\n  assert.equal(record.get('b'), undefined,\n    '.remove() should remove the key passed in');\n\n  assert.end();\n});\n"
  },
  {
    "path": "test/index.js",
    "content": "'use strict';\n\nrequire('require-all')(__dirname);\n"
  },
  {
    "path": "test/rx.js",
    "content": "'use strict';\n\nimport test from 'tape';\nimport irecord from '../index.js';\n\ntest('.subscribe', (assert) => {\n  assert.plan(3);\n\n  const original = {\n    a: 'a',\n    b: 'b'\n  };\n  const record = irecord(original);\n\n  record.subscribe(\n    ({ value, previous }) => {\n      assert.pass('should emit change events.');\n\n      assert.deepEqual(value.toJS(), {\n        a: 'a',\n        b: 'b',\n        c: 'c'\n      }, 'new value should be passed.');\n\n      assert.deepEqual(previous.toJS(), original,\n        'previous value should be passed.');\n\n    },\n    (err) => { assert.fail('err: ' + err); },\n    () => { assert.pass('complete'); }\n  );\n\n  record.set('c', 'c');\n});\n\ntest('.filter', (assert) => {\n  assert.plan(1);\n\n  const original = {\n    a: 'a',\n    b: 'b'\n  };\n  const record = irecord(original);\n\n  record.filter(({value}) => {\n    return value.toJS().c === 'again';\n  }).subscribe(({ value }) => {\n    assert.equal(value.toJS().c, 'again',\n      `should filter out changes that don't match the predicate`);\n  });\n\n  record.set('a', 'changed');\n  record.set('c', 'c');\n  record.set('c', 'again');\n  assert.end();\n});\n"
  },
  {
    "path": "test/stampit.js",
    "content": "'use strict';\n\nimport stampit from 'stampit';\nimport test from 'tape';\nimport irecord from '../index.js';\n\ntest('stamp composition with irecord', (assert) => {\n  assert.plan(1);\n\n  const record = irecord({\n    a: 'a',\n    b: 'b'\n  });\n\n  const stamp = stampit({\n    methods: {\n      countProps () {\n        return Object.keys(this.toJS()).length;\n      }\n    }\n  });\n\n  const composedRecord = stampit.compose(\n    record.stamp,\n    stamp\n  ).create();\n\n  assert.equal(composedRecord.countProps(), 2,\n    'should expose irecord methods');\n});\n"
  }
]