{"_id":"@adamldoyle/use-provided-context","_rev":"5-c659e0482a4bcc037ca03378231f3448","name":"@adamldoyle/use-provided-context","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@adamldoyle/use-provided-context","version":"1.0.0","main":"dist/index.js","module":"dist/index.esm.js","types":"dist/index.d.ts","repository":{"type":"git","url":"https://github.com/adamldoyle/use-provided-context"},"license":"MIT","scripts":{"prepare":"yarn run build","build":"yarn run prettify && yarn run lint && yarn run test:coverage && yarn run bundle","bundle":"rollup -c","prettify":"prettier --write src/**","lint":"eslint 'src/**/*.{js,ts,tsx}'","test":"jest src/** --runInBand","test:watch":"jest src/** --watch --runInBand","test:coverage":"jest src/** --silent --collect-coverage --runInBand","storybook":"start-storybook -p 6006 --quiet","storybook:docs":"start-storybook -p 6007 --docs --quiet","storybook:build":"build-storybook"},"peerDependencies":{"react":"^17.0.0","react-dom":"^17.0.0"},"dependencies":{},"devDependencies":{"@babel/core":"^7.14.2","@rollup/plugin-commonjs":"^17.0.0","@rollup/plugin-node-resolve":"^11.0.1","@storybook/addon-actions":"^6.2.9","@storybook/addon-essentials":"^6.2.9","@storybook/addon-links":"^6.2.9","@storybook/react":"^6.2.9","@testing-library/react":"^11.2.7","@testing-library/react-hooks":"^6.0.0","@types/jest":"^26.0.23","@types/react":"^17.0.5","@types/react-dom":"^17.0.5","@typescript-eslint/eslint-plugin":"^4.23.0","@typescript-eslint/parser":"^4.23.0","babel-jest":"^26.6.3","babel-loader":"^8.2.2","babel-preset-react-app":"^10.0.0","eslint":"^7.26.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.0","eslint-plugin-react":"^7.23.2","eslint-plugin-react-hooks":"^4.2.0","identity-obj-proxy":"^3.0.0","jest":"^26.6.3","prettier":"^2.3.0","react":"^17.0.2","react-dom":"^17.0.2","rollup":"^2.36.1","rollup-plugin-copy":"^3.3.0","rollup-plugin-dts":"^3.0.2","rollup-plugin-peer-deps-external":"^2.2.0","rollup-plugin-postcss":"^3.1.2","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","ts-jest":"^26.4.4","typescript":"^4.2.4"},"description":"Hook for accessing context while enforcing that the context was provided.","_id":"@adamldoyle/use-provided-context@1.0.0","dist":{"shasum":"1b837edeb5062c44f7fa40c6343ef32f95bccb7a","integrity":"sha512-cGeXOwAGLNlRz9+neOkFXLId3BBHlQKVCPlSNdnZ/vwhzC89T0ji8CyHYLrURyLZOWmrgtBxE7/O2DIkzaRhag==","tarball":"https://registry.npmjs.org/@adamldoyle/use-provided-context/-/use-provided-context-1.0.0.tgz","fileCount":9,"unpackedSize":6201,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhu2ITCRA9TVsSAnZWagAA+DwP/2s1y2mwdWbagy5aT71/\nr5pxEeQZ+nhfTONnnj91ICJ4I0nVUgTonU8LmJLtfVpPjQ7sXuW8dSv6O4yG\nIpbBfwXMVo6HC1tzvfM4mFi4Nm5IhSLlxthhEdn7xTDGJFy99r3J4jmKHf15\nn34UL68JYj1wR9bi0VFx04dy6o4Nu4iUvkkNjC6Eu3p6NsNxMMe3IMt9zR10\nOqUrYTJKDHbeCfYNADdgY403EY7Rk8aK5KAqlXiyAciByyFn30THYF7+WpNY\nBnvtqdbQwozO4ET4LvdI+pKU6a63CI/ygt0XoC5+ORb78Oh5oyZj+lfwgAzr\novNKfGpspE8NM3FNhlobhO+9vhwP3FK6SIgD6M/DOiqrFdNwDWlXPTYq59RZ\n5DRWIGvSR5x84HrrOz1w8NnK9SmdfJD18RAZsgEtOdhkY7Hh7X8xv5YoWiUU\nOQ7z/2Z/5hycYy4/jq1z2aE5De6wNnsnM1/vQQuJA494n32wbofe+iy2mZvZ\nTAVvuhiOs7h4P/v/aOx9ovFonDaWciqXE0/RLrbz+rNQ6Qv+evSuQ3JoupeK\nWL6z4t0SdkO48z1DJYXzCPNXbE4BzO/nO3iIpv2DOONteKjVbeLLr5F7oQep\n3CXvMFsfRUPc9rZeQZ7Cd6DLdllR2ra0InAaDD31913sFblavN7N1kxuB1YV\nUW9w\r\n=HDl4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDLgT37ij+XdTxE0Ywsq9j8Cd8969iTlYsMGcr0F4e5lAiEA0b4fAdERuG24mNMusHvEM+rUm1yQZrguEDHO57kMNA4="}]},"_npmUser":{"name":"adamldoyle","email":"adamldoyle@gmail.com"},"directories":{},"maintainers":[{"name":"adamldoyle","email":"adamldoyle@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-provided-context_1.0.0_1635438968799_0.8296774906273496"},"_hasShrinkwrap":false},"1.1.0":{"name":"@adamldoyle/use-provided-context","version":"1.1.0","main":"dist/index.js","module":"dist/index.esm.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/adamldoyle/use-provided-context.git"},"license":"MIT","scripts":{"prepare":"yarn run build","build":"yarn run prettify && yarn run lint && yarn run test:coverage && yarn run bundle","bundle":"rollup -c","prettify":"prettier --write src/**","lint":"eslint 'src/**/*.{js,ts,tsx}'","test":"jest src/** --runInBand","test:watch":"jest src/** --watch --runInBand","test:coverage":"jest src/** --silent --collect-coverage --runInBand","storybook":"start-storybook -p 6006 --quiet","storybook:docs":"start-storybook -p 6007 --docs --quiet","storybook:build":"build-storybook"},"peerDependencies":{"react":"^17.0.0 || ^18.0.0","react-dom":"^17.0.0 || ^18.0.0"},"dependencies":{},"devDependencies":{"@babel/core":"^7.14.2","@rollup/plugin-commonjs":"^17.0.0","@rollup/plugin-node-resolve":"^11.0.1","@storybook/addon-actions":"^6.2.9","@storybook/addon-essentials":"^6.2.9","@storybook/addon-links":"^6.2.9","@storybook/react":"^6.2.9","@testing-library/react":"^11.2.7","@testing-library/react-hooks":"^6.0.0","@types/jest":"^26.0.23","@types/react":"^18.2.36","@types/react-dom":"^18.2.14","@typescript-eslint/eslint-plugin":"^4.23.0","@typescript-eslint/parser":"^4.23.0","babel-jest":"^26.6.3","babel-loader":"^8.2.2","babel-preset-react-app":"^10.0.0","eslint":"^7.26.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.0","eslint-plugin-react":"^7.23.2","eslint-plugin-react-hooks":"^4.2.0","identity-obj-proxy":"^3.0.0","jest":"^26.6.3","prettier":"^2.3.0","react":"^18.2.0","react-dom":"^18.2.0","rollup":"^2.36.1","rollup-plugin-copy":"^3.3.0","rollup-plugin-dts":"^3.0.2","rollup-plugin-peer-deps-external":"^2.2.0","rollup-plugin-postcss":"^3.1.2","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","ts-jest":"^26.4.4","typescript":"^4.2.4"},"gitHead":"9c1d875d28700d798e434ef4bd642cf9a0406ab5","description":"Hook for accessing context while enforcing that the context was provided.","bugs":{"url":"https://github.com/adamldoyle/use-provided-context/issues"},"homepage":"https://github.com/adamldoyle/use-provided-context#readme","_id":"@adamldoyle/use-provided-context@1.1.0","_nodeVersion":"14.18.3","_npmVersion":"6.14.15","dist":{"integrity":"sha512-OLhaHo3WvJQlmXVXm3iv5y7u4IP0XiZ1CneVLU7XBuiLaRc3AW1hcDM9CldX4LNTYxQgIdBE994P6rywEn72qg==","shasum":"dcc4f3cccd18fb3c33b824a98b49d1d3e59f13aa","tarball":"https://registry.npmjs.org/@adamldoyle/use-provided-context/-/use-provided-context-1.1.0.tgz","fileCount":7,"unpackedSize":6225,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGjvHW4V2x6NHTqouCJxudafRW83E4GOoyVEFwZvRtWnAiAjqHwIe1ytHMikk948Wp8n15/8a+wj5pcp1ebnU86uOg=="}]},"_npmUser":{"name":"adamldoyle","email":"adamldoyle@gmail.com"},"directories":{},"maintainers":[{"name":"adamldoyle","email":"adamldoyle@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-provided-context_1.1.0_1699372046801_0.17252133457093421"},"_hasShrinkwrap":false}},"time":{"created":"2021-10-28T02:26:28.136Z","0.0.0":"2021-10-28T02:26:28.335Z","modified":"2023-11-07T15:47:27.116Z","1.0.0":"2021-10-28T16:36:08.953Z","1.1.0":"2023-11-07T15:47:26.965Z"},"maintainers":[{"name":"adamldoyle","email":"adamldoyle@gmail.com"}],"description":"Hook for accessing context while enforcing that the context was provided.","repository":{"type":"git","url":"git+https://github.com/adamldoyle/use-provided-context.git"},"license":"MIT","readme":"# use-provided-context\n\nHook for accessing context while enforcing that the context was provided.\n\n## Features\n\n1. Allows providing an undefined default value for context but requiring context is defined when you go to use it (by being provided from a Provider)\n2. Typescript safe - the response type won't include undefined so you don't need to check for it\n3. Throws an error when a context is used without being provided (to be handled by whatever error handling you have in place)\n\n## Installation\n\n1. `yarn add @adamldoyle/use-provided-context`\n\n## Examples\n\n- https://adamldoyle-use-provided-context.netlify.app\n\nOR\n\n- `yarn storybook`\n\nOR\n\n```\ninterface IStoryContext {\n  value: string;\n}\n\n// Context is initialized as undefined and only given a value via some defined provider\nconst StoryContext = createContext<IStoryContext | undefined>(undefined);\nStoryContext.displayName = 'StoryContext';\n\nconst StoryComponent: FC = () => {\n  // StoryContext is guaranteed to provide IStoryContext in a typesafe way, an undefined context will throw an error\n  const { value } = useProvidedContext(StoryContext);\n\n  return <>Value from context: {value}</>;\n};\n```\n\n## Development\n\n1. `yarn install`\n2. `yarn build`\n\n## Contributors\n\n[Adam Doyle](https://github.com/adamldoyle)\n\n## License\n\nMIT\n","readmeFilename":"README.md","homepage":"https://github.com/adamldoyle/use-provided-context#readme","bugs":{"url":"https://github.com/adamldoyle/use-provided-context/issues"}}