{"name":"dot-object","description":"dot-object makes it possible to transform and read (JSON) objects using dot notation.","version":"2.1.2","author":{"name":"Rob Halff","email":"rob.halff@gmail.com"},"repository":{"type":"git","url":"git://github.com/rhalff/dot-object.git"},"bugs":{"url":"https://github.com/rhalff/dot-object/issues"},"main":"index","bin":{"dot-object":"./bin/dot-object"},"scripts":{"test":"gulp test","watch":"gulp watch","lint":"gulp lint","dist":"gulp dist"},"standard":{"globals":["it","describe","beforeEach"]},"devDependencies":{"eslint":"^6.6.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.18.2","eslint-plugin-node":"^10.0.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","gulp":"^4.0.2","gulp-beautify":"^3.0.0","gulp-eslint":"^6.0.0","gulp-headerfooter":"^1.0.3","gulp-mocha":"^7.0.2","gulp-rename":"^1.4.0","gulp-uglify":"^3.0.2","gulp-util":"^3.0.8","mocha":"6.x.x","should":"13.x.x","underscore.string":"latest"},"keywords":["json","filter","transform","dot notation","dot"],"dependencies":{"commander":"^4.0.0","glob":"^7.1.5"},"gitHead":"ee628c20e7de0c1d84d67ab9cf81c9e5fa5fa1b7","homepage":"https://github.com/rhalff/dot-object#readme","_id":"dot-object@2.1.2","_nodeVersion":"11.9.0","_npmVersion":"6.12.1","dist":{"integrity":"sha512-Hx7gYDQfb4umAku7VJW0fr3SXXTaghfBhYNbc4eHTjkgPMoY4DAw210j76mSSlV9LiTozVswT462e4xL7w3GZA==","shasum":"571fece46f16368193bbe39265b8ec7804c5b0f4","tarball":"http://registry-npm.ywwl.com/dot-object/download/dot-object-2.1.2.tgz","fileCount":38,"unpackedSize":106598,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdvgCXCRA9TVsSAnZWagAA/EIP/igyyTlt0I3XVJAdDBdW\nFFkVKojbGTAvulwL+EA6wSneYzIIAfHVhJATJHLKUA0ACQUizZ5XY1BXJatQ\n3jYtRPTKNu3ACv6BZZBkD0aBkVrdrls61tp5vySjupZ0YOdn+p6JZQddi7Hb\nlFoQPl8i8H6XzFst0Rp1EgxnhAYm27c+IZML1yrS281LlReIDVe9ezDDU5jo\nExoAjHle9GI66S8osqxK8rgGjexx+Mn/CRZvcF/GL5rQTMH2dfX0skN2TzKi\nIU0mMxEpOS7AlUDOh9dqPmYLuWoJoSxUStI2CcJi0ouXtiYJ7z/iz222aIMm\n9u5bt+nKcL4SUdZMDamFF3HsVGcc6vjWiZh0ewm3iOvegYNQ95b0zP67s46Y\no91/xRNqV9BchVM98KFofw3IM03g1kS2S3OOQwGmAx9/QE4MtFhpwbjjtAfB\n11pnXs/y0gFXJ/ybYXX+fME9S3R17jyp0m2bwnKV2kuPqiTlRgb9XQSqETFH\nNfps+fa25/tW6o+y4u9TNATLN3WNWNz0gw2IFQd5VEawMxmrcjX7tGrRnfhB\nn3/iBhUejEm6VfG6jxS31uMJZMdOEObkaXxCWJFlTYZ2Mp5SbR6AcafHxBSE\nkRXIRgq2sb8ovv/rwIpv3gaOl8pg3HzE/tBhV/j++x0yZizPZyPlKNkktFml\ndI/9\r\n=lpwv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHMm/d+lsLMWa2DwNYKWS0f64F0wydsYAayhLV98Ov4QAiEAiSLfa9Hz62HLVRvbQNHoAgMWBOj/QirJtrO8ozt/ELY="}],"size":21431,"noattachment":false,"key":"/dot-object/-/dot-object-2.1.2.tgz"},"maintainers":[{"name":"rhalff","email":"rob.halff@gmail.com"}],"_npmUser":{"name":"rhalff","email":"rob.halff@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dot-object_2.1.2_1572733079016_0.13095909331586508"},"_hasShrinkwrap":false,"readme":"[![Build Status](https://travis-ci.org/rhalff/dot-object.png)](https://travis-ci.org/rhalff/dot-object)\n\nDot-Object\n========\n\nDot-Object makes it possible to transform javascript objects using dot notation.\n\n### Installation\n\nInstall from npm:\n```\n  npm install dot-object --save\n```\n\nInstall from bower:\n\n```\n  bower install dot-object --save\n```\n\n### Download\n\n  * Development version: https://unpkg.com/dot-object/dist/dot-object.js *Uncompressed with Comments*\n  * Production version: https://unpkg.com/dot-object/dist/dot-object.min.js *Minified*\n\n## Usage\n\n#### Move a property within one object to another location\n```javascript\nvar dot = require('dot-object');\n\nvar obj = {\n  'first_name': 'John',\n  'last_name': 'Doe'\n};\n\ndot.move('first_name', 'contact.firstname', obj);\ndot.move('last_name', 'contact.lastname', obj);\n\nconsole.log(obj);\n\n{\n  contact: {\n    firstname: 'John',\n    lastname: 'Doe'\n  }\n}\n\n```\n\n#### Copy property from one object to another\n```javascript\nvar dot = require('dot-object');\n\nvar src = {\n  name: 'John',\n  stuff: {\n    phone: {\n      brand: 'iphone',\n      version: 6\n    }\n  }\n};\n\nvar tgt = {name: 'Brandon'};\n\ndot.copy('stuff.phone', 'wanna.haves.phone', src, tgt);\n\nconsole.log(tgt);\n\n{\n  name: 'Brandon',\n  wanna: {\n    haves: {\n      phone: {\n        brand: 'iphone',\n        version: 6\n      }\n    }\n  }\n}\n\n```\n\n#### Transfer property from one object to another\n\nDoes the same as copy but removes the value from the source object:\n\n```javascript\ndot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt);\n\n// src: {\"name\":\"John\",\"stuff\":{}}\n// tgt: {\"name\":\"Brandon\",\"wanna\":{\"haves\":{\"phone\":{\"brand\":\"iphone\",\"version\":6}}}\n```\n\n\n#### Expand to an object\n\n```javascript\nvar dot = require('dot-object');\n\nvar row = {\n  'id': 2,\n  'contact.name.first': 'John',\n  'contact.name.last': 'Doe',\n  'contact.email': 'example@gmail.com',\n  'contact.info.about.me': 'classified',\n  'devices[0]': 'mobile',\n  'devices[1]': 'laptop',\n  'some.other.things.0': 'this',\n  'some.other.things.1': 'that'\n};\n\ndot.object(row);\n\nconsole.log(row);\n\n{\n  \"id\": 2,\n  \"contact\": {\n    \"name\": {\n      \"first\": \"John\",\n      \"last\": \"Doe\"\n    },\n    \"email\": \"example@gmail.com\",\n    \"info\": {\n      \"about\": {\n        \"me\": \"classified\"\n      }\n    }\n  },\n  \"devices\": [\n    \"mobile\",\n    \"laptop\"\n  ],\n  \"some\": {\n    \"other\": {\n      \"things\": [\n        \"this\",\n        \"that\"\n      ]\n    }\n  }\n}\n```\n\nTo convert manually per string use:\n```javascript\nvar dot = require('dot-object');\n\nvar tgt = { val: 'test' };\ndot.str('this.is.my.string', 'value', tgt);\n\nconsole.log(tgt);\n\n{\n  \"val\": \"test\",\n  \"this\": {\n    \"is\": {\n      \"my\": {\n        \"string\": \"value\"\n      }\n    }\n  }\n}\n```\n\n#### Pick a value using dot notation:\n\nPicks a value from the object without removing it.\n\n```js\nvar dot = require('dot-object');\n\nvar obj = {\n some: {\n   nested: {\n     value: 'Hi there!'\n   }\n }\n};\n\nvar val = dot.pick('some.nested.value', obj);\nconsole.log(val);\n\nHi there!\n```\n\n#### Delete/Remove a value using dot notation:\n\nRemove and delete mostly behave the same, but in case of a path addressing array items:\n\n  - `delete` will re-index the array.\n  - `remove` will retain array indexes \n\n```js\nvar dot = require('dot-object');\n\nvar obj = {\n a: 'Hi There!',\n nested: {\n   array: [ \n     'Veni',\n     'Vidi',\n     'Vici',\n   ]\n }\n};\n\nvar val = dot.delete('a', obj);\nconsole.log(val);\n\nHi There!\n\n// To remove an item and directly update any array indexes use:\nvar val = dot.delete('nested.array[1]', obj);\nconsole.log(val);\n\nVidi\n\n// Remove a value but retain array indexes. \nvar val = dot.remove('nested.array[1]', obj);\n\n// To remove multiple paths at once:\nvar val = dot.remove(['nested.array[0]', 'nested.array[2]'], obj);\n```\n\n### Using modifiers\n\nYou can use modifiers to translate values on the fly.\n\nThis example uses the [underscore.string](https://github.com/epeli/underscore.string) library.\n\n\n\n```javascript\nvar dot = require('dot-object');\n\nvar _s = require('underscore.string');\n\nvar row = {\n  'nr': 200,\n  'doc.name': '    My Document   '\n};\n\nvar mods = {\n  \"doc.name\": [_s.trim, _s.underscored],\n};\n\ndot.object(row, mods);\n\nconsole.log(row);\n```\n\n```\n{\n  \"nr\": 200,\n  \"doc\": {\n    \"name\": \"my_document\"\n  }\n}\n```\n\nOr using .str() directy:\n\n```javascript\n\nvar dot = require('dot-object');\nvar _s = require('underscore.string');\nvar obj = { id: 100 };\n\n// use one modifier\ndot.str('my.title', 'this is my title', obj, _s.slugify);\n\n// multiple modifiers\ndot.str('my.title', '   this is my title  ', obj, [_s.trim, _s.slugify]);\n\nconsole.log(obj);\n```\nResult:\n```json\n{\n  \"id\": 100,\n  \"my\": {\n    \"title\": \"this-is-my-title\"\n  }\n}\n```\n\n#### Transform object\n\n```javascript\nvar dot = require('dot-object');\n\nvar source = {\n  \"id\": 1,\n  \"contact\": {\n    \"firstName\": \"John\",\n    \"lastName\": \"Doe\",\n    \"email\": \"example@gmail.com\",\n  }\n}\n\nvar recipe = {\n  'id': 'nr',\n  'contact.firstName': 'name.first',\n  'contact.lastName': 'name.last',\n  'contact.email': 'email'\n};\n\nvar tgt = {}\ndot.transform(recipe, source, tgt);\n\n// OR\n\nvar tgt = dot.transform(recipe, source);\n\nconsole.log(tgt);\n{\n  \"nr\": 1,\n  \"name\": {\n    \"first\": \"John\",\n    \"last\": \"Doe\"\n  },\n  \"email\": \"example@gmail.com\"\n}\n```\n\n\n### Convert object to dotted-key/value pair\n\n```javascript\nvar dot = require('dot-object');\n\nvar obj = {\n  id: 'my-id',\n  nes: { ted: { value: true } },\n  other: { nested: { stuff: 5 } },\n  some: { array: ['A', 'B'] }\n};\n\nvar tgt = dot.dot(obj);\n\n// or\n\nvar tgt = {};\ndot.dot(obj, tgt);\n\nconsole.log(tgt);\n```\nResult:\n```json\n{\n  \"id\": \"my-id\",\n  \"nes.ted.value\": true,\n  \"other.nested.stuff\": 5,\n  \"some.array[0]\": \"A\",\n  \"some.array[1]\": \"B\"\n}\n```\n\n### Keep array\n\nSet keepArray to true.\n\n```javascript\nvar dot = require('dot-object');\n\nvar obj = {\n  id: 'my-id',\n  other: [1, 2, 3],\n  some: { array: ['A', 'B'] }\n};\n\ndot.keepArray = true;\nvar tgt = dot.dot(obj);\n\nconsole.log(tgt);\n```\nResult:\n```json\n{\n  \"id\": \"my-id\",\n  \"other\": [1, 2, 3],\n  \"some.array\": [\"A\", \"B\"]\n}\n```\n\n## Using a different separator\n\nIf you do not like dot notation, you are free to specify a different separator.\n\n```javascript\nvar Dot = require('dot-object');\n\nvar dot = new Dot('->');\n\nvar _s = require('underscore.string');\n\nvar row = {\n  'nr': 200,\n  'doc->name': '    My Document   '\n};\n\nvar mods = {\n  \"doc->name\": [_s.trim, _s.underscored],\n};\n\ndot.object(row, mods);\n\nconsole.log(row);\n```\n\n```\n{\n  \"nr\": 200,\n  \"doc\": {\n    \"name\": \"my_document\"\n  }\n}\n```\n\n## Transforming SQL results to JSON\n\nSQL translation on the fly:\n\n```javascript\n // TODO\n\n```\n\n\n> Copyright © 2013 Rob Halff, released under the MIT license\n","publish_time":1572733079273,"_cnpm_publish_time":1572733079273,"dist-tags":{"latest":"2.1.5"}}