107 lines
5.1 KiB
JSON
107 lines
5.1 KiB
JSON
|
{
|
||
|
"_args": [
|
||
|
[
|
||
|
{
|
||
|
"raw": "idx@^2.1.0",
|
||
|
"scope": null,
|
||
|
"escapedName": "idx",
|
||
|
"name": "idx",
|
||
|
"rawSpec": "^2.1.0",
|
||
|
"spec": ">=2.1.0 <3.0.0",
|
||
|
"type": "range"
|
||
|
},
|
||
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/xdl"
|
||
|
]
|
||
|
],
|
||
|
"_from": "idx@>=2.1.0 <3.0.0",
|
||
|
"_id": "idx@2.2.0",
|
||
|
"_inCache": true,
|
||
|
"_location": "/idx",
|
||
|
"_nodeVersion": "8.7.0",
|
||
|
"_npmOperationalInternal": {
|
||
|
"host": "s3://npm-registry-packages",
|
||
|
"tmp": "tmp/idx-2.2.0.tgz_1509119500882_0.5113535716664046"
|
||
|
},
|
||
|
"_npmUser": {
|
||
|
"name": "zertosh",
|
||
|
"email": "zertosh@gmail.com"
|
||
|
},
|
||
|
"_npmVersion": "5.4.2",
|
||
|
"_phantomChildren": {},
|
||
|
"_requested": {
|
||
|
"raw": "idx@^2.1.0",
|
||
|
"scope": null,
|
||
|
"escapedName": "idx",
|
||
|
"name": "idx",
|
||
|
"rawSpec": "^2.1.0",
|
||
|
"spec": ">=2.1.0 <3.0.0",
|
||
|
"type": "range"
|
||
|
},
|
||
|
"_requiredBy": [
|
||
|
"/xdl"
|
||
|
],
|
||
|
"_resolved": "https://registry.npmjs.org/idx/-/idx-2.2.0.tgz",
|
||
|
"_shasum": "8544749f9faba6409822b5d9488ba5bc77b8fbfe",
|
||
|
"_shrinkwrap": null,
|
||
|
"_spec": "idx@^2.1.0",
|
||
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/xdl",
|
||
|
"bugs": {
|
||
|
"url": "https://github.com/facebookincubator/idx/issues"
|
||
|
},
|
||
|
"dependencies": {},
|
||
|
"description": "Utility function for traversing properties on objects and arrays.",
|
||
|
"devDependencies": {
|
||
|
"babel-cli": "^6.23.0",
|
||
|
"babel-jest": "^19.0.0",
|
||
|
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||
|
"babel-preset-env": "^1.1.11",
|
||
|
"jest": "^19.0.2"
|
||
|
},
|
||
|
"directories": {},
|
||
|
"dist": {
|
||
|
"integrity": "sha512-EdlesREUoUC4nvHr+6EQ9z3bbbYEORdhJIUDOuBoJ6BuVFd3Rqf68FyI8PH57UY/iqSeRQ4IMqeHXxwoFXrOxg==",
|
||
|
"shasum": "8544749f9faba6409822b5d9488ba5bc77b8fbfe",
|
||
|
"tarball": "https://registry.npmjs.org/idx/-/idx-2.2.0.tgz"
|
||
|
},
|
||
|
"files": [
|
||
|
"README.md",
|
||
|
"lib/"
|
||
|
],
|
||
|
"homepage": "https://github.com/facebookincubator/idx#readme",
|
||
|
"jest": {
|
||
|
"testEnvironment": "node",
|
||
|
"rootDir": "src"
|
||
|
},
|
||
|
"license": "MIT",
|
||
|
"main": "lib/idx.js",
|
||
|
"maintainers": [
|
||
|
{
|
||
|
"name": "zertosh",
|
||
|
"email": "zertosh@gmail.com"
|
||
|
},
|
||
|
{
|
||
|
"name": "yungsters",
|
||
|
"email": "yungsters@gmail.com"
|
||
|
},
|
||
|
{
|
||
|
"name": "fb",
|
||
|
"email": "opensource+npm@fb.com"
|
||
|
}
|
||
|
],
|
||
|
"name": "idx",
|
||
|
"optionalDependencies": {},
|
||
|
"readme": "# idx [![Circle Status](https://circleci.com/gh/facebookincubator/idx/tree/master.svg?style=shield&circle-token=da61f3cf105f22309c8ca0ba4482daa538bf5349)](https://circleci.com/gh/facebookincubator/idx)\n\n`idx` is a utility function for traversing properties on objects and arrays.\n\nIf an intermediate property is either null or undefined, it is instead returned.\nThe purpose of this function is to simplify extracting properties from a chain\nof maybe-typed properties.\n\nThis module exists as a stop-gap solution because JavaScript does not currently\nsupport [optional chaining](https://github.com/tc39/proposal-optional-chaining).\n\n## Usage\n\nConsider the following type for `props`:\n\n```javascript\ntype User = {\n user: ?{\n name: string,\n friends: ?Array<User>,\n }\n};\n```\n\nGetting to the friends of my first friend would resemble:\n\n```javascript\nprops.user &&\nprops.user.friends &&\nprops.user.friends[0] &&\nprops.user.friends[0].friends\n```\n\nInstead, `idx` allows us to safely write:\n\n```javascript\nidx(props, _ => _.user.friends[0].friends)\n```\n\nThe second argument must be a function that returns one or more nested member\nexpressions. Any other expression has undefined behavior.\n\n## Flow Type\n\n[Flow](https://flow.org/) understands the `idx` idiom:\n\n```javascript\n// @flow\n\nimport idx from 'idx';\n\nfunction getName(props: User): ?string {\n return idx(props, _ => _.user.name);\n}\n```\n\n## Babel Transform\n\nThe `idx` runtime function exists for the purpose of illustrating the expected\nbehavior and is not meant to be executed. The `idx` function is used in\nconjunction with a Babel plugin that replaces it with better performing code.\n\nThis babel plugin searches for requires or imports to the `idx` module and\nreplaces all its usages, so this code:\n\n```javascript\nimport idx from 'idx';\n\nfunction getFriends() {\n return idx(props, _ => _.user.friends[0].friends)\n};\n```\n\ngets transformed to something like:\n\n```javascript\nfunction getFriends() {\n props.user == null ? props.user :\n props.user.friends == null ? props.user.friends :\n props.user.friends[0] == null ? props.user.friends[0] :\n return props.user.friends[0].friends\n}\n```\n\n(note that the original `import` gets also removed).\n\nIt's possible to customize the name of the import/require, so code that is not\ndirectly requiring the `idx` npm package can also get transformed:\n\n```javascript\n{\n plugins: [\n [\"babel-plugin-idx\", {\n importName: './idx',\n }]\n ]\n}\n```\n\n## License\n\n`idx` is [MIT licensed](./LICENSE).\n",
|
||
|
"readmeFilename": "README.md",
|
||
|
"repository": {
|
||
|
"type": "git",
|
||
|
"url": "git+https://github.com/facebookincubator/idx.git"
|
||
|
},
|
||
|
"scripts": {
|
||
|
"build": "scripts/build.sh",
|
||
|
"prepublish": "yarn run build && cp ../../README.md .",
|
||
|
"test": "jest"
|
||
|
},
|
||
|
"types": "lib/idx.d.ts",
|
||
|
"version": "2.2.0"
|
||
|
}
|