diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-09 14:59:30 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-09 14:59:30 -0400 |
| commit | ce294f2591279e1fc342b6c3da4a2e0c22c805a2 (patch) | |
| tree | c995d3b69814c57bb0b2f93069fd0a712c92b445 /app/node_modules/okschema | |
| parent | 3a28bacfc38cd0244ada6e74655d1e30d81d4d34 (diff) | |
Don't expose object refs in public APIs ya dummy!
Make sure to deep clone them input/output objects
to maintain immutability y'hear
Diffstat (limited to 'app/node_modules/okschema')
| -rw-r--r-- | app/node_modules/okschema/index.js | 10 | ||||
| -rw-r--r-- | app/node_modules/okschema/package.json | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 8871a99..4b215d1 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -1,4 +1,4 @@ -var assign = require('object-assign'); +var cloneDeep = require('lodash.clonedeep'); var mschema = require('mschema'); var v = require('validator'); @@ -68,7 +68,7 @@ function OKSchema(spec) { if (!(this instanceof OKSchema)) return new OKSchema(spec); if (!spec) throw new Error('No spec provided to OKSchema'); - spec = assign({}, spec); + spec = cloneDeep(spec); // Cache the mschema version of our spec this._mschemaSpec = Object.keys(spec).reduce(function(cache, prop) { // If custom type, return its parent spec @@ -83,8 +83,10 @@ function OKSchema(spec) { }, {}); Object.defineProperty(this, 'spec', { - value: spec, - writable: false + get: function() { + return cloneDeep(spec); + }, + enumerable: true }); } diff --git a/app/node_modules/okschema/package.json b/app/node_modules/okschema/package.json index 21214fa..21a7c67 100644 --- a/app/node_modules/okschema/package.json +++ b/app/node_modules/okschema/package.json @@ -9,8 +9,8 @@ "author": "OKFocus", "license": "None", "dependencies": { + "lodash.clonedeep": "^3.0.0", "mschema": "^0.5.5", - "object-assign": "^2.0.0", "validator": "^3.37.0" } } |
