{"_id":"o-is","_rev":"11-e6b712f545fc79a3ca051796d510cd64","name":"o-is","description":"Serializable object assertions.","dist-tags":{"latest":"0.7.1"},"versions":{"0.5.0":{"name":"o-is","version":"0.5.0","description":"Serializable object assertions.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"echo 'See main repo to run tests'"},"repository":{"type":"git","url":"git+https://github.com/AGhost-7/dyna-table.git"},"keywords":["Assertion","Conditional","Serialization","Storable","Conditions"],"author":{"name":"Jonathan Boudreau","email":"jonathan.boudreau.92@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/AGhost-7/dyna-table/issues"},"homepage":"https://github.com/AGhost-7/dyna-table#readme","dependencies":{"lodash.assign":"^4.0.8","lodash.clone":"^4.3.2","lodash.get":"^4.2.1"},"_id":"o-is@0.5.0","_shasum":"38dc21b7968004dcd651f5fcd3dbb28a06addbaa","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.3.2","_npmUser":{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"},"dist":{"shasum":"38dc21b7968004dcd651f5fcd3dbb28a06addbaa","tarball":"https://registry.npmjs.org/o-is/-/o-is-0.5.0.tgz","integrity":"sha512-Ky6yBDwWcBhTGWRjOvay3jOZbfQj6bxGJasOzdwlLeN7lL1Kul1QOjPOSPBlmsLL9Oj0twLCjCf9jZ5W3LddeA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICzCGq/sQJq7U5sxPg+oCaOk4C0aAytPmZetdUVkCH5tAiEArUnB68AYy6UmxXlhUx/O+EX3WUq05munofq8gciL9G0="}]},"maintainers":[{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/o-is-0.5.0.tgz_1461029893134_0.05293808411806822"}},"0.5.1":{"name":"o-is","version":"0.5.1","description":"Serializable object assertions.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"echo 'See main repo to run tests'"},"repository":{"type":"git","url":"git+https://github.com/AGhost-7/dyna-table.git"},"keywords":["Assertion","Conditional","Serialization","Storable","Conditions"],"author":{"name":"Jonathan Boudreau","email":"jonathan.boudreau.92@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/AGhost-7/dyna-table/issues"},"homepage":"https://github.com/AGhost-7/dyna-table#readme","dependencies":{"lodash.assign":"^4.0.8","lodash.clone":"^4.3.2","lodash.get":"^4.2.1"},"_id":"o-is@0.5.1","_shasum":"97c049c6a65d25efa1a68300ac0132bfda91a1ed","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.3.2","_npmUser":{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"},"dist":{"shasum":"97c049c6a65d25efa1a68300ac0132bfda91a1ed","tarball":"https://registry.npmjs.org/o-is/-/o-is-0.5.1.tgz","integrity":"sha512-5KKUZz2l0INCXvdQCTS/KXP2OrwbmlD0dQ7Tv6wGs/9IGIQkQT6S6R+nBXurMIwhnTwyCeDQ9TH8WPOclBbsNQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBHzQOHuSSfTJmFEFs14CSs7L90DiVRHwmqtg7e68buzAiEA4E7VAbFBsYUY2ALMI8wfd31Ojbb+HGlUknjplN3KgB4="}]},"maintainers":[{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/o-is-0.5.1.tgz_1461071189122_0.3479504743590951"}},"0.5.2":{"name":"o-is","version":"0.5.2","description":"Serializable object assertions.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"echo 'See main repo to run tests'"},"repository":{"type":"git","url":"git+https://github.com/AGhost-7/dyna-table.git"},"keywords":["Assertion","Conditional","Serialization","Storable","Conditions","Validation","Schema"],"author":{"name":"Jonathan Boudreau","email":"jonathan.boudreau.92@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/AGhost-7/dyna-table/issues"},"homepage":"https://github.com/AGhost-7/dyna-table#readme","dependencies":{"lodash.assign":"^4.0.8","lodash.clone":"^4.3.2","lodash.get":"^4.2.1"},"devDependencies":{"source-map-support":"^0.4.0"},"_id":"o-is@0.5.2","_shasum":"f45fdc3c79cd5515a9a2210f17c173967f9c1bc9","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.2.6","_npmUser":{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"},"dist":{"shasum":"f45fdc3c79cd5515a9a2210f17c173967f9c1bc9","tarball":"https://registry.npmjs.org/o-is/-/o-is-0.5.2.tgz","integrity":"sha512-WlJJNKZuJdPNDPauFThOJpNziKHSMsGuQwkF1b8M2TOZuFqcClXKcQ0SYC9bsWbHNlHiHIvOn/f69vt4c44vRQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBRgJLBe3klA1PGDVxgi8Ym/bgOYJtTxuyYQct91Qc7RAiBVEyWcHZ2j39X+QsLPFHQ6xCuEvfCzbP+R1b5cwNeGdg=="}]},"maintainers":[{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/o-is-0.5.2.tgz_1461433142480_0.119205750990659"}},"0.6.0":{"name":"o-is","version":"0.6.0","description":"Serializable object assertions.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"echo 'See main repo to run tests'"},"repository":{"type":"git"},"keywords":["Assertion","Conditional","Serialization","Storable","Conditions","Validation"],"author":{"name":"Jonathan Boudreau","email":"jonathan.boudreau.92@gmail.com"},"license":"MIT","dependencies":{"lodash.assign":"^4.0.8","lodash.clone":"^4.3.2","lodash.get":"^4.2.1"},"devDependencies":{"o-is-common-suite":"^0.0.0"},"engine":{"node":">=6.9.0"},"_id":"o-is@0.6.0","_shasum":"5d4bbfb709114e998b3af63c28a8e73a203aa1c9","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.12.2","_npmUser":{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"},"dist":{"shasum":"5d4bbfb709114e998b3af63c28a8e73a203aa1c9","tarball":"https://registry.npmjs.org/o-is/-/o-is-0.6.0.tgz","integrity":"sha512-1ThBI9mp8ApNBhnozWs0n9IhzBvTq11SgkbIDBKI8yN9fuYRs/0lZIVz0UxH3YFzi2gSfk8pkTzpnCKN8/VFEw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDyghquIzinzHeh8+XGLpe7oze6Ds4y5tiiiamIq27VxAiEAqxVFqA39lRMR8T3pBjqdXeaBGK9Pv6EGfbzAa63YsuM="}]},"maintainers":[{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/o-is-0.6.0.tgz_1513039008642_0.09509432804770768"}},"0.7.1":{"name":"o-is","version":"0.7.1","description":"Serializable object assertions.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"echo 'See main repo to run tests'"},"repository":{"type":"git"},"keywords":["Assertion","Conditional","Serialization","Storable","Conditions","Validation"],"author":{"name":"Jonathan Boudreau","email":"jonathan.boudreau.92@gmail.com"},"license":"MIT","dependencies":{"lodash.assign":"^4.0.8","lodash.clone":"^4.3.2","lodash.get":"^4.2.1"},"devDependencies":{"o-is-common-suite":"^0.7.1"},"engine":{"node":">=6.9.0"},"_id":"o-is@0.7.1","_shasum":"6ae3cd7c48ba13dfd2da31af90a52e9deae95cf0","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.12.0","_npmUser":{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"},"dist":{"shasum":"6ae3cd7c48ba13dfd2da31af90a52e9deae95cf0","tarball":"https://registry.npmjs.org/o-is/-/o-is-0.7.1.tgz","integrity":"sha512-J3OTx1IEJz76sox+rZGUAEhfK22qIRezj+ZpHSCtLcRAXFzJGBN7cWzA3XPH85aZa3fswnPVcSJPjuh+ZTGvVg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDiKo1BqRZODt7D61LEW9pShB14oIXWnPausm2LkB4T/QIgDQitZ6aZ/ZMY6eN8IDf2Q/OKtDBPoVAMCiXe/6cJIAQ="}]},"maintainers":[{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/o-is-0.7.1.tgz_1515115146483_0.022669155150651932"}}},"readme":"Module for testing objects. `o-is` == \"Object Is\". There's a variety of uses\nfor this module, such as schema validation.\n\nMotivation for this is that there isn't anything of expressive/flexible enough \nfor my needs. The closest thing would have to be Joi, but for some reason there\nisn't much in terms of serialization solutions. I also don't like the API...\n\nPerformance should be pretty good, since the underlying data structure used to\nstore the data is already json-convertable (just stringify it). The method\nchaining only provides a more fluid api.\n\n```javascript\nconst oIs = require('o-is');\nconst test = oIs()\n\t.equal('foo.bar', 'hello world!')\n\t.test;\n\ntest({\n\tfoo: {\n\t\tbar: 'hello world!'\n\t}\n}); // =>  true\n```\n\nThis module can be useful for creating serializable conditions based on a certain context.\nIn other words, user defined logic.\n```javascript\nconst data = oIs()\n\t.null('created')\n\t.serialize(); // outputs an array of objects ready to be stored.\n\n// ... imagine pulling this out of a db\nconst test = oIs(data).test;\n\nif(test({ created: new Date() })) {\n\tsendEmail({...}); // etc...\n}\n\n```\n\n## Core Comparison Methods\n\n### `equal(key, value)`\nDoes a strict equality check against a property in the object.\n\n```javascript\nconst result = oIs.equal('foo', 1).test({ foo: 1 }) // => true\n```\n\n### `propsEqual(key1, key2)`\nDoes a strict equality check on two properties in the object.\n\n```javascript\nconst result = oIs()\n\t.propsEqual('foo', 'bar')\n\t.test({ foo: 1, bar: 1 }) // => true\n```\n\n### `null(key)`\nWill be true if the key is equal to null (not strict).\n\n```javascript\nconst result = oIs().null('foo').test({ foo: null }) // => true\n```\n### `true(key)`\nChecks if the given property is equal to true.\n\n```javascript\nconst result = oIs().true('foo').test({ foo: false }) // => returns false\n```\n\n### `false(key)`\nChecks if the given property is equal to false.\n\n```javascript\nconst result = oIs().false('foo').test({ foo: false }) // => true\n```\n\n### `gt(key, value)`\nChecks if the given property is greater than the given value.\n\n\n```javascript\nconst result1 = oIs().gt('one', 1).test({ one: 1 }) // => false\n\nconst result2 = oIs().gt('two', 1).test({ two: 2 }) // => true\n```\n\n### `lt(key, value)`\nChecks if the given property is less than the given value\n\n```javascript\nconst result = oIs().lt('one', 2).test({ one: 1 }) // => true\n```\n\n### `any(key, values)`\nChecks if the given property(key) is equal to any of the values.\n\n```javascript\nconst result = oIs().any('letter', ['a', 'b']).test({ letter: 'a' }) // => true\n```\n\n## Not (Logical Inversion)\nWhen you call `not`, the next method chain's result will be inverted.\n```javascript\noIs()\n\t.not().equal('a', 1)\n\t.not().exist('c')\n\t.test({ a: 2 }); // => true\n```\n\n## Conditional Properties\n```javascript\noIs()\n\t.if()\n\t\t.equal('type', 'human')\n\t.then()\n\t\t.exist('name')\n\t.end()\n\t.assert({\n\t\ttype: 'bear',\n\t\tage: 5\n\t}); // doesn't throw an error\n```\n\n## Binding to a specific key\n```javascript\noIs()\n\t.bind('fullName')\n\t.equal('firstName', 'Jonathan')\n\t.equal('lastName', 'Boudreau')\n\t.end()\n\t.test({\n\t\tfullName: {\n\t\t\tfirstName: 'Jonathan',\n\t\t\tlastName: 'Boudreau'\n\t\t}\n\t}); // => true\n```\n\n## Or Statement\n```javascript\noIs()\n\t.or()\n\t\t.equal('a', 1)\n\t\t.equal('a', 2)\n\t.end()\n\t.test({ a: 2 }); // => true\n\noIs()\n\t.or()\n\t\t.equal('a', 1)\n\t\t.and()\n\t\t\t.equal('a', 2)\n\t\t\t.equal('b', 3)\n\t\t.end()\n\t.end()\n\t.test({ a: 2, b: 3 }) // => true\n```\n\n## Composition\nBecause the instances are immutable, you can use an existing instance to\nconcatenate it with another.\n```javascript\n// you can currently do this\nconst cond = oIs().equal('name', 'Jonathan');\n// You get a new object which will test for both properties.\nconst merged = oIs().equal('fullName.lastName', 'Boudreau').concat(cond);\n```\n\n## Extensions\nThis module is somewhat extendable. The first argument is the series of asserts runners,\nand the second argument is the set of methods to add to the builder.\n```javascript\nconst objectIs = oIs.extend({\n\tfoo(context, args) {\n\t\treturn oIs.get(context, args.key) === 'bar';\n\t}\n}, {\n\tfoo(key) {\n\t\treturn this.concat({\n\t\t\ttype: 'foo', // this specifies what assertion to call\n\t\t\tkey\n\t\t});\n\t}\n});\n\nobjectIs\n\t.foo('a')\n\t.exist('today') // previous methods remain, but they can be overriden.\n\t.test({ today: new Date(), a: 'bar' }); // returns true!\n```\n\nOr even...\n\n```javascript\nconst eql = require('deep-eql');\nconst objectIs = oIs.extend({\n\teql(context, args) {\n\t\treturn eql(args.compare);\n\t}\n}, {\n\teql(compare) {\n\t\treturn this.concat({\n\t\t\ttype: 'eql',\n\t\t\tcompare\n\t\t});\n\t}\n});\n\n```\n\nTo keep this module lightweight I decided to not include a ton of depdencies.\nInstead the module aims to be extendable for your specific needs. Mainly, this\nmodule defines a \"grammar\", you can add whatever \"nouns\" you want.\n\n","maintainers":[{"name":"aghost7","email":"jonathan.boudreau.92@gmail.com"}],"time":{"modified":"2022-06-22T15:06:38.210Z","created":"2016-04-19T01:38:14.535Z","0.5.0":"2016-04-19T01:38:14.535Z","0.5.1":"2016-04-19T13:06:30.640Z","0.5.2":"2016-04-23T17:39:03.285Z","0.6.0":"2017-12-12T00:36:48.959Z","0.7.1":"2018-01-05T01:19:06.641Z"},"keywords":["Assertion","Conditional","Serialization","Storable","Conditions","Validation"],"repository":{"type":"git"},"author":{"name":"Jonathan Boudreau","email":"jonathan.boudreau.92@gmail.com"},"license":"MIT","readmeFilename":"readme.md"}