{"id":15364141,"url":"https://github.com/int64ago/chain","last_synced_at":"2025-04-15T09:29:57.537Z","repository":{"id":57116645,"uuid":"105874544","full_name":"int64ago/chain","owner":"int64ago","description":"[npm] Partial implementation for Optional Chaining in ES5","archived":false,"fork":false,"pushed_at":"2019-05-16T11:43:40.000Z","size":7,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T09:36:04.519Z","etag":null,"topics":["optional-chaining"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/int64ago.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-05T10:00:23.000Z","updated_at":"2024-01-16T12:42:24.000Z","dependencies_parsed_at":"2022-09-12T15:03:48.274Z","dependency_job_id":null,"html_url":"https://github.com/int64ago/chain","commit_stats":null,"previous_names":["int64ago/optional-chaining"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int64ago%2Fchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int64ago%2Fchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int64ago%2Fchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int64ago%2Fchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/int64ago","download_url":"https://codeload.github.com/int64ago/chain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249042668,"owners_count":21203332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["optional-chaining"],"created_at":"2024-10-01T13:10:22.094Z","updated_at":"2025-04-15T09:29:57.519Z","avatar_url":"https://github.com/int64ago.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chain\n\n[![NPM version][npm-image]][npm-url]\n[![npm download][download-image]][download-url]\n[![Travis][travis-image]][travis-url]\n[![Coverage][coverage-image]][coverage-url]\n\n[npm-image]: https://img.shields.io/npm/v/@hspkg/chain.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@hspkg/chain\n[download-image]: https://img.shields.io/npm/dm/@hspkg/chain.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@hspkg/chain\n[travis-image]: https://img.shields.io/travis/com/int64ago/chain.svg?style=flat-square\n[travis-url]: https://travis-ci.com/int64ago/chain\n[coverage-image]: https://img.shields.io/coveralls/int64ago/chain.svg?style=flat-square\n[coverage-url]: https://coveralls.io/github/int64ago/chain\n\nPartial implementation for [Optional Chaining](https://github.com/tc39/proposal-optional-chaining) in ES5\n\n## API\n\n```js\nvar chain: (sourceObject: object, propertyString: string, defaultValue: any) =\u003e any\n```\n\n## Examples\n\n`npm i @hspkg/chain -S`\n\n```js\nvar chain = require('@hspkg/chain');\n\nvar testObj = {\n  code: 200,\n  data: {\n    list: [\n      { id: 1, name: 'name1' },\n      { id: 2, name: 'name2' }\n    ],\n    page: {\n      current: 1,\n      total: 200\n    }\n  }\n};\n// testObj?.code\nconsole.log(chain(testObj, '.code')); // 200\n// testObj?.data?.page?.current\nconsole.log(chain(testObj, '.data.page.current')); // 1\n// testObj?.data?.list?.[0]?.id\nconsole.log(chain(testObj, '.data.list[0].id')); // 1\n// testObj?.wrong?.path\nconsole.log(chain(testObj, '.wrong.path')); // undefined\n// testObj?.wrong?.path || 666\nconsole.log(chain(testObj, '.wrong.path', 666)); // 666\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint64ago%2Fchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fint64ago%2Fchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint64ago%2Fchain/lists"}