{"_id":"@arnu515/tiny-invariant","_rev":"2-6988c2fb02e18c2e113712e3ecf6365b","name":"@arnu515/tiny-invariant","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"@arnu515/tiny-invariant","version":"1.0.0","description":"A tiny invariant function","author":{"name":"Alex Reardon","email":"alexreardon@gmail.com"},"license":"MIT","keywords":["invariant","error","assert","asserts"],"repository":{"type":"git","url":"git+https://github.com/alexreardon/tiny-invariant.git"},"bugs":{"url":"https://github.com/alexreardon/tiny-invariant/issues"},"main":"dist/tiny-invariant.cjs.js","module":"dist/tiny-invariant.esm.js","types":"dist/tiny-invariant.d.ts","sideEffects":false,"size-limit":[{"path":"dist/tiny-invariant.min.js","limit":"217B"},{"path":"dist/tiny-invariant.js","limit":"217B"},{"path":"dist/tiny-invariant.cjs.js","limit":"206B"},{"path":"dist/tiny-invariant.esm.js","import":"foo","limit":"98B"}],"scripts":{"test":"yarn jest","test:size":"yarn build && yarn size-limit","prettier:write":"yarn prettier --debug-check src/** test/**","prettier:check":"yarn prettier --write src/** test/**","typescript:check":"yarn tsc --noEmit src/*.ts test/*.ts","validate":"yarn prettier:check && yarn typescript:check","build:clean":"rimraf dist","build:flow":"cp src/tiny-invariant.js.flow dist/tiny-invariant.cjs.js.flow","build:typescript":"tsc ./src/tiny-invariant.ts --emitDeclarationOnly --declaration --outDir ./dist","build:dist":"yarn rollup --config rollup.config.js","build":"yarn build:clean && yarn build:dist && yarn build:typescript","prepublishOnly":"yarn build"},"devDependencies":{"@rollup/plugin-replace":"^3.0.0","@rollup/plugin-typescript":"^8.3.0","@size-limit/preset-small-lib":"^6.0.4","@types/jest":"^27.0.2","@types/rollup":"^0.54.0","expect-type":"^0.13.0","jest":"^27.3.1","prettier":"^2.4.1","rimraf":"^3.0.2","rollup":"^2.58.3","rollup-plugin-terser":"^7.0.2","size-limit":"^6.0.4","ts-jest":"^27.0.7","tslib":"^2.3.1","typescript":"^4.4.4"},"gitHead":"ebc4d4383df442758262ed384795bb31bd69498b","homepage":"https://github.com/alexreardon/tiny-invariant#readme","_id":"@arnu515/tiny-invariant@1.0.0","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-uM3KHOQ1ADYXfhbWDc4iEZTqyPW5RUAXKD7H7lN5HDzpobycPp9hJRB2GDkSisvsR9s+U5CJM1qoIwOu/e0d3w==","shasum":"0afe2a4553531a9feea65d2bf7b70bc9dd0d85ca","tarball":"https://registry.npmjs.org/@arnu515/tiny-invariant/-/tiny-invariant-1.0.0.tgz","fileCount":10,"unpackedSize":9167,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiGEqsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoasg//V5N5Bwhbxoabjm+nvlk6L+seDTqemLGsEmmr3AVD0G4D5QaV\r\ndaNcj9pOea4Ym6O9IMq9FNUL+hcGA2/WfC1QRtybq2PcfB41gg7+KoPt+EyX\r\nglB9u1HBvJi1TVKSQ5goLHsyPxbirexxU9C88CALKz4et80EiRsZyR96kj0Y\r\nsSooSPX8B6aurTc/KvegRiN3EqAr1sja+sgE0SZw41Yl98jCDGrpzvdleT0X\r\nJQQdLLl2VBwyqRHEd+BGkRkOxLg/2kgRIyYwWveyvFlT4nSvY1z07e7PRzkG\r\nSwe2CxhU7mTKz/j3rEzRbIduqvT3y1wZ/JkgyJUKOI6NITjmLkoboIIR89JO\r\nODlTsXPnJ1FKV4V31ctuA7i9pQAwyULxtOlUNK12z7ObtwxDHQwynqoIqCHO\r\nXloKgg872j0nlEqjkyDRG4+Ktn3tKsF8K/OgrNuRJU5CcnIp95PFW/2BNND9\r\nd7McxYLYX8Rn57NcL9YbvnUlwzlA/bHDsodeazX19ZsCuAGhC0DPU+UyJr4c\r\nCAcN2C92vX5H+WRFLzYOMsJTmmqNvSSSkS3kDwioPxELyz5xyvdzRAXI6UCW\r\nZIDHqgxXq9lE8Br3CnpD7G2TvKji5YkXrbY3+sbANF8PTcX2tYLFZeo7cFaY\r\n4oxsHo7yXO3dRHMz9MeoIq1cmaKrhi1khTY=\r\n=0vKO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIExA+HQYH5PTACXZF7oOjKXPYcL97EmAPsPRShuSc4rCAiAioXH/SG1aF3z3SizwklkijUrYeJxbCl60IAWisffyIA=="}]},"_npmUser":{"name":"arnu515","email":"arnu5152@gmail.com"},"directories":{},"maintainers":[{"name":"arnu515","email":"arnu5152@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tiny-invariant_1.0.0_1645759148849_0.9331603283335974"},"_hasShrinkwrap":false},"1.3.0":{"name":"@arnu515/tiny-invariant","version":"1.3.0","description":"A tiny invariant function. Forked from https://npmjs.com/package/tiny-invariant","author":{"name":"arnu515"},"license":"MIT","keywords":["invariant","error","assert","asserts"],"repository":{"type":"git","url":"git+https://github.com/arnu515/tiny-invariant.git"},"bugs":{"url":"https://github.com/arnu515/tiny-invariant/issues"},"main":"dist/tiny-invariant.cjs.js","module":"dist/tiny-invariant.esm.js","types":"dist/tiny-invariant.d.ts","sideEffects":false,"scripts":{"test":"yarn jest","prettier:write":"yarn prettier --debug-check src/** test/**","prettier:check":"yarn prettier --write src/** test/**","typescript:check":"yarn tsc --noEmit src/*.ts test/*.ts","validate":"yarn prettier:check && yarn typescript:check","build:clean":"rimraf dist","build:flow":"cp src/tiny-invariant.js.flow dist/tiny-invariant.cjs.js.flow","build:typescript":"tsc ./src/tiny-invariant.ts --emitDeclarationOnly --declaration --outDir ./dist","build:dist":"yarn rollup --config rollup.config.js","build":"yarn build:clean && yarn build:dist && yarn build:typescript","prepublishOnly":"yarn build"},"devDependencies":{"@rollup/plugin-replace":"^3.0.0","@rollup/plugin-typescript":"^8.3.0","@types/jest":"^27.0.2","@types/rollup":"^0.54.0","expect-type":"^0.13.0","jest":"^27.3.1","prettier":"^2.4.1","rimraf":"^3.0.2","rollup":"^2.58.3","rollup-plugin-terser":"^7.0.2","ts-jest":"^27.0.7","tslib":"^2.3.1","typescript":"^4.4.4"},"gitHead":"bc472470eb6276cb683ddfc1e4284550cc7b0548","homepage":"https://github.com/arnu515/tiny-invariant#readme","_id":"@arnu515/tiny-invariant@1.3.0","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-0XPCDf5nc7xk0AZB3uv/z6fwyNUsgDcxSCoNsVLtKwmti1+k8b7mXV+I4wFAY7Ok9vTwkj/uZXpsqUEIzQRZyg==","shasum":"4858efc807382d70fbcd558b6e16cfacd842fa36","tarball":"https://registry.npmjs.org/@arnu515/tiny-invariant/-/tiny-invariant-1.3.0.tgz","fileCount":10,"unpackedSize":9716,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBZuke3mhJ9ihU/1RmOMhl2aEK4YCwkPKnCdA6RGSDwmAiASMLqlcOBHYB4jBcNIM9KndBFkgifcdRhUWsulad5t/g=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjHT6xACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoVsg//YWLFpSCLaNaJJ3uDPjZY80Jpgm5x0G/ltsUiDyoneLJaSern\r\nX9jWbpZjOvgbiXUR+21tUv2q4OnHlAg0rbgqsZ6lhcgOdFNjWE88zut1i599\r\n1tTuG31ub0PrJDh/QtYqa8nNEv75B4Bfe+aG8dVbA+NPtbU7Jv+GK/g90QNs\r\n7w5YkENMpRXQvl5fmnl1akrYP/29HEq3MaWl1/cTJpYNBXQyqEPtq8Bn1x2L\r\neOySFOqV34co2oUFK6WF7rMFok7XistJXWgxYQGKqyyjP8oLh5o9Fix+GrFk\r\n6FUomKROzJd1xPbxjuJpC9Eoj3L4/HCrvys77x8ZRtmlUGyqa1sIHvhu51QF\r\nxNmmOlyn9XWA25rqOS9xakboS/iule3bXAUMxkmI0DThRS+k0i2cPAWXplac\r\nCmV4ZJmTJHOKtWgVR2QyZQ0hbbQsfHTH1ECmMLPOQvKOkmSThltFg8zl9/Tr\r\nZhvnWGTpS2BSIQo2v6bfrR88/vJOY6rk/toLnUqZ3JK9ljCTyPGEFukcI8j+\r\n/okDCfkamJip+32D/iciIDsr0M1t96TNsPYaHGwu1HanvoZ2W4n+nQlmB3Oy\r\niDhTA37h6FS6PR2+TA5L/Vzx2zKntJL8QyDf6H7nMPV751SiWmGgVyytH+DM\r\nJ6vypSwrT1J174rr+rXfKgvt9USWhqgv4CY=\r\n=wQer\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"arnu515","email":"arnu5152@gmail.com"},"directories":{},"maintainers":[{"name":"arnu515","email":"arnu5152@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tiny-invariant_1.3.0_1662860977602_0.6483140401347474"},"_hasShrinkwrap":false}},"time":{"created":"2022-02-25T03:19:08.796Z","1.0.0":"2022-02-25T03:19:08.989Z","modified":"2022-09-11T01:49:37.853Z","1.3.0":"2022-09-11T01:49:37.777Z"},"maintainers":[{"name":"arnu515","email":"arnu5152@gmail.com"}],"description":"A tiny invariant function. Forked from https://npmjs.com/package/tiny-invariant","homepage":"https://github.com/arnu515/tiny-invariant#readme","keywords":["invariant","error","assert","asserts"],"repository":{"type":"git","url":"git+https://github.com/arnu515/tiny-invariant.git"},"author":{"name":"arnu515"},"bugs":{"url":"https://github.com/arnu515/tiny-invariant/issues"},"license":"MIT","readme":"# @arnu515/tiny-invariant 🔬💥\n\nA tiny [`invariant`](https://www.npmjs.com/package/invariant) fork with some things changed.\n\n## Things that changed\n\n- No prefix by default\n- Specify custom prefix\n\n**ORIGINAL README BELOW**\n\n## What is `invariant`?\n\nAn `invariant` function takes a value, and if the value is [falsy](https://github.com/getify/You-Dont-Know-JS/blob/bdbe570600d4e1107d0b131787903ca1c9ec8140/up%20%26%20going/ch2.md#truthy--falsy) then the `invariant` function will throw. If the value is [truthy](https://github.com/getify/You-Dont-Know-JS/blob/bdbe570600d4e1107d0b131787903ca1c9ec8140/up%20%26%20going/ch2.md#truthy--falsy), then the function will not throw.\n\n```js\nimport invariant from 'tiny-invariant';\n\ninvariant(truthyValue, 'This should not throw!');\n\ninvariant(falsyValue, 'This will throw!');\n// Error('Invariant violation: This will throw!');\n```\n\nYou can also provide a function to generate your message, for when your message is expensive to create\n\n```js\nimport invariant from 'tiny-invariant';\n\ninvariant(value, () => getExpensiveMessage());\n```\n\n## Why `tiny-invariant`?\n\nThe [`library: invariant`](https://www.npmjs.com/package/invariant) supports passing in arguments to the `invariant` function in a sprintf style `(condition, format, a, b, c, d, e, f)`. It has internal logic to execute the sprintf substitutions. The sprintf logic is not removed in production builds. `tiny-invariant` has dropped all of the sprintf logic. `tiny-invariant` allows you to pass a single string message. With [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) there is really no need for a custom message formatter to be built into the library. If you need a multi part message you can just do this: `invariant(condition, 'Hello, ${name} - how are you today?')`\n\n## Type narrowing\n\n`tiny-invariant` is useful for correctly narrowing types for `flow` and `typescript`\n\n```ts\nconst value: Person | null = { name: 'Alex' }; // type of value == 'Person | null'\ninvariant(value, 'Expected value to be a person');\n// type of value has been narrowed to 'Person'\n```\n\n## API: `(condition: any, message?: string | (() => string)) => void`\n\n- `condition` is required and can be anything\n- `message` optional `string` or a function that returns a `string` (`() => string`)\n\n## Installation\n\n```bash\n# yarn\nyarn add tiny-invariant\n\n# npm\nnpm install tiny-invariant --save\n```\n\n## Dropping your `message` for kb savings!\n\nBig idea: you will want your compiler to convert this code:\n\n```js\ninvariant(condition, 'My cool message that takes up a lot of kbs');\n```\n\nInto this:\n\n```js\nif (!condition) {\n  if ('production' !== process.env.NODE_ENV) {\n    invariant(false, 'My cool message that takes up a lot of kbs');\n  } else {\n    invariant(false);\n  }\n}\n```\n\n- **Babel**: recommend [`babel-plugin-dev-expression`](https://www.npmjs.com/package/babel-plugin-dev-expression)\n- **TypeScript**: recommend [`tsdx`](https://github.com/jaredpalmer/tsdx#invariant) (or you can run `babel-plugin-dev-expression` after TypeScript compiling)\n\nYour bundler can then drop the code in the `\"production\" !== process.env.NODE_ENV` block for your production builds to end up with this:\n\n```js\nif (!condition) {\n  invariant(false);\n}\n```\n\n- rollup: use [rollup-plugin-replace](https://github.com/rollup/rollup-plugin-replace) and set `NODE_ENV` to `production` and then `rollup` will treeshake out the unused code\n- Webpack: [instructions](https://webpack.js.org/guides/production/#specify-the-mode)\n\n## Builds\n\n- We have a `es` (EcmaScript module) build\n- We have a `cjs` (CommonJS) build\n- We have a `umd` (Universal module definition) build in case you needed it\n\nWe expect `process.env.NODE_ENV` to be available at module compilation. We cache this value\n\n## That's it!\n\n🤘\n","readmeFilename":"README.md"}