{"name":"property-expr","version":"2.0.1","description":"tiny util for getting and setting deep object props safely","main":"index.js","types":"index.d.ts","scripts":{"test":"node ./test.js","debug":"node --inspect-brk ./test.js"},"repository":{"type":"git","url":"git+https://github.com/jquense/expr.git"},"keywords":["expr","expression","setter","getter","deep","property","Justin-Beiber","accessor"],"author":{"name":"@monasticpanic Jason Quense"},"license":"MIT","prettier":{"singleQuote":true,"semi":false},"gitHead":"126ac16e84c9bfb923044ce5e7a7cb75184056c5","bugs":{"url":"https://github.com/jquense/expr/issues"},"homepage":"https://github.com/jquense/expr#readme","_id":"property-expr@2.0.1","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-/8Uv556zn0ONP2P4EeqNlVp8RN2Y/BeHyOWtG1QxOG+NBMYI7u3VQSNEJW2JgrQRnGSiqvwdQc6k6DV6ivuH4w==","shasum":"a677e10cf00b30657d5d64da4cb7c2cd8811f680","tarball":"http://registry-npm.ywwl.com/property-expr/download/property-expr-2.0.1.tgz","fileCount":6,"unpackedSize":9857,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYnpKCRA9TVsSAnZWagAAlG0P/jBlDdboFcbdya3rufPj\nBU+sOLs9CeInXHlqgwoaJ130ecoCdhcJR8FJ/yU7A5edLV0PuvWYHCADKSDp\no3hs1ku1ryMcJnSBytN+mToh0xwzC/klhtsXWnfC8Ep2yY3GR1PfBT08E8I+\nNl5BZfsFWCxUKagUr1BeH5Ng8FSKI7onExtTripwcg/jtFfzoe+rBf8+MdDo\nnt4LxkTS474eYH1eUqHs1OqKPir6VzlUZqeLinYd37flIrK6brQHLlqZmWWL\n8xMX3HWJluzIGz5Ath6NEZcrXYtwxGySodsCif40yugkt3EQeQ4dr7YXKk9p\ngTc8N5xoe3EsTG+DGbFrMvhAatqKnwlOBJvJBn9Em/zAMDAyjGrbam+9huTX\n79KXf0fHvF0wUtoYQNC29oJuFatY/+mpMvUwFkwS3NJWW8rve3IfM4m9uPck\n8T22zgXYx7RJAbB+5a5GWFbPCbcg0ruVg8UTpsJyzBqYteJ08iRJwajLfRuv\n2ZuuKNV1d1cagdmHAtIbsqMzUNTFDIgKN2VyA9k0EggGCRJgnEwujgkvvVZ+\nPnY/VUrrT/BoOys7ACtLol4VVjtzgfVZjzqb5cbcFlXfGBIZGbP594XRgz9K\nijjtqve7rvCJtGTwgay+VuTe9vBPUzBF9zx2n4dB0y+OYCJJznqTWooPd7Dc\nWz99\r\n=Ww/R\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFc+3mwUgt7HKqEWZ+nmC0/EYJCiGaNYBRIZ4Dx6yYPrAiBIB1Ormwd9IWHaVxxYWyP98+0E/6XWpMXKEryMw55CQA=="}],"size":4190,"noattachment":false,"key":"/property-expr/-/property-expr-2.0.1.tgz"},"maintainers":[{"name":"monastic.panic","email":"monastic.panic@gmail.com"}],"_npmUser":{"name":"monastic.panic","email":"monastic.panic@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/property-expr_2.0.1_1583512137607_0.6519144440756042"},"_hasShrinkwrap":false,"readme":"# expr\n\nTiny property path utilities, including path parsing and metadata and deep property setters and getters\n\n    npm install property-expr\n\n## Use\n\nSetters and getters:\n\n```js\nlet expr = require('property-expr')\nlet obj = {\n  foo: {\n    bar: ['hi', { buz: { baz: 'found me!' } }]\n  }\n}\n\nlet getBaz = expr.getter('foo.bar[1][\"buz\"].baz')\nlet setBaz = expr.setter('foo.bar[1][\"buz\"].baz')\n\nconsole.log(getBaz(obj)) // => 'found me!'\nsetBaz(obj, 'set me!')\nconsole.log(obj.foo.bar[1].buz.baz) // => 'set me!'\n```\n\n### `getter(expression, [ safeAccess ])`\n\nReturns a function that accepts an obj and returns the value at the supplied expression. You can create a \"safe\" getter, which won't error out when accessing properties that don't exist, reducing existance checks befroe property access:\n\n```js\nexpr.getter('foo.bar.baz', true)({ foo: {} }) // => undefined\n//instead of val = foo.bar && foo.bar.baz\n```\n\n### `setter(expression)`\n\nReturns a function that accepts an obj and a value and sets the property pointed to by the expression to the supplied value.\n\n### `expr(expression, [ safeAccess], [ paramName = 'data'])`\n\nReturns a normalized expression string pointing to a property on root object\n`paramName`.\n\n    expr.expr(\"foo['bar'][0].baz\", true, 'obj') // => \"(((obj.foo || {})['bar'] || {})[0])\"\n\n### `split(path) -> Array`\n\nReturns an array of each path segment.\n\n```js\nexpr.split(\"foo['bar'][0].baz\") // [ \"foo\", \"'bar'\", \"0\", \"baz\"]\n```\n\n### `forEach(path, iterator[, thisArg])`\n\nIterate through a path but segment, with some additional helpful metadata about the segment. The iterator function is called with: `pathSegment`, `isBracket`, `isArray`, `idx`, `segments`\n\n```js\nexpr.forEach('foo[\"bar\"][1]', function(\n  pathSegment,\n  isBracket,\n  isArray,\n  idx,\n  segments\n) {\n  // 'foo'   -> isBracket = false, isArray = false, idx = 0\n  // '\"bar\"' -> isBracket = true,  isArray = false, idx = 1\n  // '0'     -> isBracket = false, isArray = true,  idx = 2\n})\n```\n\n### `normalizePath(path)`\n\nReturns an array of path segments without quotes and spaces.\n\n```js\nexpr.normalizePath('foo[\"bar\"][ \"1\" ][2][ \" sss \" ]')\n// ['foo', 'bar', '1', '2', ' sss ']\n```\n\n### `new Cache(maxSize)`\n\nJust an utility class, returns an instance of cache. When the max size is exceeded, cache clears its storage.\n\n```js\nvar cache = new Cache(2)\ncache.set('a', 123) // returns 123\ncache.get('a') // returns 123\ncache.clear()\n\ncache.set('a', 1)\ncache.set('b', 2) // cache contains 2 values\ncache.set('c', 3) // cache was cleaned automatically and contains 1 value\n```\n\n### CSP\n\nThis pacakge used to rely on `new Function` to compile setters and getters into fast\nreusable functions. Since `new Function` is forbidden by folks using Content Security Policy `unsafe-eval`\nwe've moved away from that approach. I believe that for most cases the perf hit is not noticable\nbut if it is in your case please reach out.\n\nIf you really want to use the old version require `property-expr/compiler` instead\n","publish_time":1583512137698,"_cnpm_publish_time":1583512137698,"dist-tags":{"latest":"2.0.6"}}