{"id":18400925,"url":"https://github.com/magicmark/deep-non-null","last_synced_at":"2025-04-12T16:59:46.550Z","repository":{"id":69481467,"uuid":"301332393","full_name":"magicmark/deep-non-null","owner":"magicmark","description":"deep-non-null","archived":false,"fork":false,"pushed_at":"2020-10-06T04:33:53.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-16T03:25:32.794Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magicmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-05T07:53:18.000Z","updated_at":"2020-10-06T04:33:55.000Z","dependencies_parsed_at":"2023-04-03T22:55:21.323Z","dependency_job_id":null,"html_url":"https://github.com/magicmark/deep-non-null","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fdeep-non-null","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fdeep-non-null/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fdeep-non-null/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fdeep-non-null/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicmark","download_url":"https://codeload.github.com/magicmark/deep-non-null/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602271,"owners_count":21131613,"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":[],"created_at":"2024-11-06T02:37:16.588Z","updated_at":"2025-04-12T16:59:46.524Z","avatar_url":"https://github.com/magicmark.png","language":"JavaScript","readme":"# deep-non-null\n\nA type guard to ensure all properties in an object are not null or undefined.\n\nUseful for unmarshalling data from the outside world (such as handling the\nresponse object from a GraphQL query)\n\n## Usage\n\n```js\nimport isDeepNonNull from 'deep-non-null';\n\nisDeepNonNull({\n    foo: {\n        bar: 'baz',\n    },\n});\n//=\u003e true\n\nisDeepNonNull({\n    foo: {\n        bar: null,\n    },\n});\n//=\u003e false\n```\n\n**Real world example**\n\n```jsx\nimport isDeepNonNull from 'deep-non-null';\n\nfunction MyComponent() {\n    const { data, error, loading } = useQuery(GET_MY_DATA);\n\n    if (loading) return 'Loading...';\n    if (error) throw error;\n    if (!isDeepNonNull) throw new Error('Response contained null attributes');\n\n    // Everything in `data` is guaranteed to be not null - which typescript should know about\n    return \u003cdiv\u003e{data.foo.bar}\u003c/div\u003e;\n}\n```\n\n_(Our 'real world' example doesn't print the attribute that was null to avoid logging [PII](https://en.wikipedia.org/wiki/Personal_data). In non production settings, you could use `options.throwError` to get a nice error message containing this.)_\n\n## Install\n\n```\n$ yarn add deep-non-null\n```\n\n## API\n\n### `isDeepNonNull`\n\nType: `Function`\u003cbr /\u003e\nSignature: `(obj: Object, options?: Object) =\u003e boolean`\n\n**Options**\n\n-   `options.throwError`: Throw an error instead of returning a boolean if null or undefined is found in the object\n\n### `isDeepNonNullWithAllowedPaths`\n\nType: `Function`\u003cbr /\u003e\nSignature: `(obj: Object, options?: Object) =\u003e boolean`\n\n**Options**\n\n-   `options.throwError`: Throw an error instead of returning a boolean if null or undefined is found in the object\n-   `options.allowedNull`: A list of [JSONPaths](https://github.com/dchester/jsonpath) to exclude from the null checking\n\n## Contact\n\n-   [@mark_larah - https://twitter.com/mark_larah](https://twitter.com/mark_larah)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicmark%2Fdeep-non-null","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicmark%2Fdeep-non-null","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicmark%2Fdeep-non-null/lists"}