{"nyc":{"include":["src/**/*.ts"],"require":["ts-node/register"],"reporter":["text-summary","html"],"extension":[".ts",".tsx"],"sourceMap":true,"instrument":true},"bugs":{"url":"https://github.com/flitbit/json-ptr/issues"},"dist":{"shasum":"530110072b65e6dd931c87eb53c33a003d86188c","tarball":"https://registry.npmjs.org/json-ptr/-/json-ptr-1.2.1-ts.d9366c0.tgz","fileCount":17,"integrity":"sha512-zmAej55CVoR8pPvqUMogYEic2srrT59MQQjciq3bJ93w1jOh3ZX6cmExeuuvo10pdCIR+lrvvQ2PubvnjWLaYA==","signatures":[{"sig":"MEUCIBS9GtycT/ZDxFwqL1Lg4XMfSkksl+q46PbHf3XV+2mjAiEAqiyxkkM0+dmkUyLqqYedKbWrcEYf1xyM5HmcTwMPsAo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":193447,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfCMDBCRA9TVsSAnZWagAAQNwP/jvdHAwum4FuLyZtXtWF\n7Q9gC37rpbcEXci4h3yhXWKPT9/raTOhVCp9QihtXiRS5UOwa8y7UFhm6glv\n6wbSSsgmrPHSoyvFIYvsq4DX7vCTMgwVLRMOZOdsDIBkR+dB2/isneWyZzJJ\nN9meLQAytesEmiqEPqU7yJ/7uPMwXd2LxGWtpV8EIdBTtTdCwCZrr4CH+0xg\nZlzt/4+Q7D0FPMI/NpBdSOI1+bCDXFA0AXldHXQCKCvfFHU+0U+8NPrk/aNI\nNVR4Ib7ESZyFO4Qn8rDSxQQN7VrZ22R++IFYePDvvdoYWqH0YUUVAEsJLzD9\nw6YarSQj35HyE5EZTXhx+CdxENYYSeMoFjVRttNJJK101mNvNvA/BplEh14F\nKF+CsAE/Z+adIZbroaZoQAquun3p2Lc+Ny1ieesndTQlUoDOycQYxw44KnMR\nnDFN/mEvWkeq9Y5VScR2WFp1xOplOet864XLsZGC6RQ25ggnY6TnCWnAtadB\n8gfyIJ0EbdOnSeUVJyM385EWPkvvul4+7rH8/DRFBU7BrO8fPc2+5464O1DN\njJ9ZWeLh29D3xgVineYT6tomAOnyapa7INSfTJcTkcZ5ya/1LmTQzRsLhy8+\nZwmJIY1iHyYwn0FlBmineEX/S1vigoyIxk7S4fBi5znfHlT92i01HeKEklq5\n2LQ6\r\n=YgKE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","name":"json-ptr","types":"dist/index.d.ts","author":{"name":"Phillip Clark","email":"phillip@flitbit.com"},"readme":"# json-ptr\n\n[![CircleCI](https://circleci.com/gh/flitbit/json-ptr/tree/master.svg?style=svg)](https://circleci.com/gh/flitbit/json-ptr/tree/master)\n\nA complete implementation of JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) for nodejs and modern browsers.\n\n## Background\n\nI wrote this a few years back when I was unable to find a _complete implementation_ of [RFC 6901](https://tools.ietf.org/html/rfc6901). It turns out that I now use the hell out of it.\n\nSince there are a few npm modules for you to choose from, see [the section on performance later in this _readme_](#user-content-performance); you can use your own judgement as to which package you should employ.\n\n## Install\n\n```bash\nnpm install json-ptr\n```\n\n## Use\n\n### [nodejs](https://nodejs.org/en/)\n\n```javascript\nimport { JsonPointer, create } from 'json-ptr';\n```\n\n### Example\n\nThere are many uses for JSON Pointers, here's one we encountered when we updated a public API and suddenly had clients sending two different message bodies to our APIs. This example is contrived to illustrate how we supported both new and old incoming messages:\n\n```ts\n// examples/versions.ts\nimport { JsonPointer } from 'json-ptr';\n\nexport type SupportedVersion = '1.0' | '1.1';\n\ninterface PrimaryGuestNamePointers {\n  name: JsonPointer;\n  surname: JsonPointer;\n  honorific: JsonPointer;\n}\nconst versions: Record<SupportedVersion, PrimaryGuestNamePointers> = {\n  '1.0': {\n    name: JsonPointer.create('/guests/0/name'),\n    surname: JsonPointer.create('/guests/0/surname'),\n    honorific: JsonPointer.create('/guests/0/honorific'),\n  },\n  '1.1': {\n    name: JsonPointer.create('/primary/primaryGuest/name'),\n    surname: JsonPointer.create('/primary/primaryGuest/surname'),\n    honorific: JsonPointer.create('/primary/primaryGuest/honorific'),\n  }\n};\n\ninterface Reservation extends Record<string, unknown> {\n  version?: SupportedVersion;\n}\n\n/**\n * Gets the primary guest's name from the specified reservation.\n * @param reservation a reservation, either version 1.0 or bearing a `version`\n * property indicating the version.\n */\nfunction primaryGuestName(reservation: Reservation): string {\n  const pointers = versions[reservation.version || '1.0'];\n  if (!pointers) {\n    throw new Error(`Unsupported reservation version: ${reservation.version}`);\n  }\n  const name = pointers.name.get(reservation) as string;\n  const surname = pointers.surname.get(reservation) as string;\n  const honorific = pointers.honorific.get(reservation) as string;\n  const names: string[] = [];\n  if (honorific) names.push(honorific);\n  if (name) names.push(name);\n  if (surname) names.push(surname);\n  return names.join(' ');\n}\n\n// The original layout of a reservation (only the parts relevant to our example)\nconst reservationV1: Reservation = {\n  guests: [{\n    name: 'Wilbur',\n    surname: 'Finkle',\n    honorific: 'Mr.'\n  }, {\n    name: 'Wanda',\n    surname: 'Finkle',\n    honorific: 'Mrs.'\n  }, {\n    name: 'Wilma',\n    surname: 'Finkle',\n    honorific: 'Miss',\n    child: true,\n    age: 12\n  }]\n  // ...\n};\n\n// The new layout of a reservation (only the parts relevant to our example)\nconst reservationV1_1: Reservation = {\n  version: '1.1',\n  primary: {\n    primaryGuest: {\n      name: 'Wilbur',\n      surname: 'Finkle',\n      honorific: 'Mr.'\n    },\n    additionalGuests: [{\n      name: 'Wanda',\n      surname: 'Finkle',\n      honorific: 'Mrs.'\n    }, {\n      name: 'Wilma',\n      surname: 'Finkle',\n      honorific: 'Miss',\n      child: true,\n      age: 12\n    }]\n    // ...\n  }\n  // ...\n};\n\nconsole.log(primaryGuestName(reservationV1));\nconsole.log(primaryGuestName(reservationV1_1));\n\n```\n\n## API Documentation\n\nThe API documentation is generated from code comments by typedoc and [hosted here](<>).\n\nWe welcome new issues if you have questions or need additional documentation.\n\n## Performance\n\nThis repository has a [companion repository that makes some performance comparisons](https://github.com/flitbit/json-pointer-comparison) between `json-ptr`, [`jsonpointer`](https://www.npmjs.com/package/jsonpointer) and [`json-pointer`](https://www.npmjs.com/package/json-pointer).\n\n**All timings are expressed as nanoseconds:**\n\n```text\n.flatten(obj)\n...\nMODULE       | METHOD  | COMPILED | SAMPLES |       AVG | SLOWER\njson-pointer | dict    |          | 10      | 464455181 |\njson-ptr     | flatten |          | 10      | 770424039 | 65.88%\njsonpointer  | n/a     |          | -       |         - |\n\n.has(obj, pointer)\n...\nMODULE       | METHOD | COMPILED | SAMPLES | AVG  | SLOWER\njson-ptr     | has    | compiled | 1000000 | 822  |\njson-ptr     | has    |          | 1000000 | 1747 | 112.53%\njson-pointer | has    |          | 1000000 | 2683 | 226.4%\njsonpointer  | n/a    |          | -       | -    |\n\n.has(obj, fragmentId)\n...\nMODULE       | METHOD | COMPILED | SAMPLES | AVG  | SLOWER\njson-ptr     | has    | compiled | 1000000 | 602  |\njson-ptr     | has    |          | 1000000 | 1664 | 176.41%\njson-pointer | has    |          | 1000000 | 2569 | 326.74%\njsonpointer  | n/a    |          | -       | -    |\n\n.get(obj, pointer)\n...\nMODULE       | METHOD | COMPILED | SAMPLES | AVG  | SLOWER\njson-ptr     | get    | compiled | 1000000 | 590  |\njson-ptr     | get    |          | 1000000 | 1676 | 184.07%\njsonpointer  | get    | compiled | 1000000 | 2102 | 256.27%\njsonpointer  | get    |          | 1000000 | 2377 | 302.88%\njson-pointer | get    |          | 1000000 | 2585 | 338.14%\n\n.get(obj, fragmentId)\n...\nMODULE       | METHOD | COMPILED | SAMPLES | AVG  | SLOWER\njson-ptr     | get    | compiled | 1000000 | 587  |\njson-ptr     | get    |          | 1000000 | 1673 | 185.01%\njsonpointer  | get    | compiled | 1000000 | 2105 | 258.6%\njsonpointer  | get    |          | 1000000 | 2451 | 317.55%\njson-pointer | get    |          | 1000000 | 2619 | 346.17%\n\n```\n\n> These results have been elided because there is too much detail in the actual. Your results will vary slightly depending on the resources available where you run it.\n\nIt is important to recognize in the performance results that _compiled_ options are faster. As a general rule, you should _compile_ any pointers you'll be using repeatedly.\n\n_Consider this example code that queries the flickr API and prints results to the console:_\n\n```javascript\n'use strict';\n\nlet ptr = require('..'),\n  http = require('http'),\n  util = require('util');\n\n// A flickr feed, tags surf,pipeline\nlet feed = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=surf,pipeline&tagmode=all&format=json&jsoncallback=processResponse';\n\n// Compile/prepare the pointers...\nlet items = ptr.create('#/items');\nlet author = ptr.create('#/author');\nlet media = ptr.create('#/media/m');\n\nfunction processResponse(json) {\n  let data = items.get(json);\n\n  if (data && Array.isArray(data)) {\n    let images = data.reduce((acc, it) => {\n      // Using the prepared pointers to select parts...\n      acc.push({\n        author: author.get(it),\n        media: media.get(it)\n      });\n      return acc;\n    }, []);\n    console.log(util.inspect(images, false, 9));\n  }\n}\n\nhttp.get(feed, function(res) {\n  let data = '';\n\n  res.on('data', function(chunk) {\n    data += chunk;\n  });\n\n  res.on('end', function() {\n    // result is formatted as jsonp... this is for illustration only.\n    data = eval(data); // eslint-disable-line no-eval\n    processResponse(data);\n  });\n}).on('error', function(e) {\n  console.log('Got error: ' + e.message);\n});\n```\n\n> \\[[example/real-world.js](https://github.com/flitbit/json-ptr/blob/master/examples/real-world.js)]\n\n## Tests\n\nTests are written using [mocha](https://mochajs.org/) and [expect.js](https://github.com/Automattic/expect.js).\n\n```bash\nnpm test\n```\n\n... or ...\n\n```bash\nmocha\n```\n\n## Releases\n\n-   2019-09-14 — **1.2.0**\n    -   Merged new `.concat` function contributed by @vuwuv, updated dependencies.\n\n-   2019-03-10 — **1.1.2**\n    -   Updated packages to remove critical security concern among dev dependencies'\n\n-   2016-07-26 — **1.0.1**\n    -   Fixed a problem with the Babel configuration\n\n-   2016-01-12 — **1.0.0**\n    -   Rolled major version to 1 to reflect breaking change in `.list(obj, fragmentId)`.\n\n-   2016-01-02 — **0.3.0**\n    -   Retooled for node 4+\n    -   Better compiled pointers\n    -   Unrolled recursive `.list` function\n    -   Added `.map` function\n    -   Fully linted\n    -   Lots more tests and examples.\n    -   Documented many previously undocumented features.\n\n-   2014-10-21 — **0.2.0**  Added #list function to enumerate all properties in a graph, producing fragmentId/value pairs.\n\n## License\n\n[MIT](https://github.com/flitbit/json-ptr/blob/master/LICENSE)\n","gitHead":"d9366c04e63084bf8e4a47af1f422809efe2bb1d","license":"MIT","scripts":{"ci":"nyc mocha __tests__/**/*.spec.ts --timeout=10000 --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml","docs":"typedoc","lint":"eslint . --ext .ts,.tsx","test":"nyc mocha __tests__/**/*.spec.ts","build":"npm run buildall","clean":"rimraf coverage dist dist.browser tmp docs","preci":"npm run cibuild","cilint":"eslint . --ext .ts,.tsx --format junit --output-file ./reports/eslint/eslint.xml","cibuild":"npm run buildall","pretest":"npm run lint","buildall":"tsc -p tsconfig.release.json && npm run build:browser && npm run build:browser-tests && npm run docs","prebuild":"npm run lint","precibuild":"npm run cilint","test:watch":"chokidar \"*.js\" \"*.json\" \"src/**/*.ts\" \"__tests__/**/*.ts\" --command \"npm run test\" --initial","build:watch":"tsc -w -p tsconfig.release.json","build:browser":"webpack","build:browser-tests":"webpack --config webpack.tests.config.js"},"_npmUser":{"name":"cerebralkungfu","email":"phillip@flitbit.com"},"homepage":"https://github.com/flitbit/json-ptr#readme","keywords":["6901","json","pointers","fragmentid"],"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/flitbit/json-ptr.git","type":"git"},"_npmVersion":"6.14.5","description":"A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.","directories":{},"maintainers":[{"name":"cerebralkungfu","email":"phillip@flitbit.com"}],"_nodeVersion":"12.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"nyc":"^15.1.0","bent":"^7.3.7","chai":"^4.2.0","mocha":"^8.0.1","eslint":"^7.4.0","rimraf":"~3.0.2","ts-node":"^8.10.2","typedoc":"^0.17.8","webpack":"^4.43.0","prettier":"~2.0.5","ts-loader":"^7.0.5","typescript":"~3.9.6","@types/bent":"^7.0.2","@types/chai":"^4.2.11","@types/node":"~14.0.19","webpack-cli":"^3.3.12","@types/debug":"^4.1.5","@types/mocha":"^7.0.2","chokidar-cli":"^2.1.0","@types/assert-plus":"^1.0.4","eslint-plugin-mocha":"^7.0.1","mocha-junit-reporter":"^2.0.0","eslint-config-prettier":"~6.11.0","@typescript-eslint/parser":"~3.6.0","@typescript-eslint/eslint-plugin":"~3.6.0"},"_npmOperationalInternal":{"tmp":"tmp/json-ptr_1.2.1-ts.d9366c0_1594409152961_0.9777389039648599","host":"s3://npm-registry-packages"},"_id":"json-ptr@1.2.1-ts.d9366c0","version":"1.2.1-ts.d9366c0"}