{"_id":"@100terres/spread","_rev":"4-9797fc630c85d7a53d5fb361363a657c","name":"@100terres/spread","dist-tags":{"latest":"1.0.0","alpha":"1.0.0-alpha.2"},"versions":{"1.0.0-alpha.0":{"name":"@100terres/spread","version":"1.0.0-alpha.0","keywords":[],"author":{"name":"Mathieu Masy","email":"masy.mathieu@gmail.com"},"license":"MIT","_id":"@100terres/spread@1.0.0-alpha.0","maintainers":[{"name":"gab100terres","email":"gab@100terres.com"}],"dist":{"shasum":"a400360e3635c83e43260e0684c04f4bda7a960b","tarball":"https://registry.npmjs.org/@100terres/spread/-/spread-1.0.0-alpha.0.tgz","fileCount":7,"integrity":"sha512-WUI6Haueb+Vxv4ECjRKjvmT9nJOjjxK9nkxNGnxguyIrWhWuGFglhnk0Q7cLpwdcopuAoegyuwuXrlV7kqsoxw==","signatures":[{"sig":"MEQCIGl2xtMTADRSKYQUkhy3yMR0KoTopcQH4A1GnDq7BFojAiBaC+nfrTxgtdrAC/NlyFt+bUVg9Mir7XEJqU4/CC2+3Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9755},"main":"./dist/spread.cjs","type":"module","_from":"file:100terres-spread-1.0.0-alpha.0.tgz","types":"./dist/spread.d.cts","module":"./dist/spread.mjs","$schema":"https://www.schemastore.org/package.json","exports":{".":{"import":"./dist/spread.mjs","require":"./dist/spread.cjs"},"./package.json":"./package.json"},"scripts":{"dev":"tsdown --watch","lint":"deno lint","test":"deno test","build":"tsdown","format":"oxfmt"},"_npmUser":{"name":"gab100terres","email":"gab@100terres.com"},"_resolved":"/tmp/8448009c179c92a1ab13e4f088f22515/100terres-spread-1.0.0-alpha.0.tgz","_integrity":"sha512-WUI6Haueb+Vxv4ECjRKjvmT9nJOjjxK9nkxNGnxguyIrWhWuGFglhnk0Q7cLpwdcopuAoegyuwuXrlV7kqsoxw==","_npmVersion":"11.8.0","description":"Ergonomic conditional spread.","directories":{},"_nodeVersion":"24.13.1","_hasShrinkwrap":false,"devDependencies":{"oxfmt":"^0.35.0","tsdown":"^0.20.3","publint":"^0.3.17","git-cliff":"^2.12.0","typescript":"^5.9.3","@std/expect":"npm:@jsr/std__expect@^1.0.17","@std/testing":"npm:@jsr/std__testing@^1.0.17","@arethetypeswrong/core":"^0.18.2"},"_npmOperationalInternal":{"tmp":"tmp/spread_1.0.0-alpha.0_1772167072166_0.19127308006233257","host":"s3://npm-registry-packages-npm-production"}},"1.0.0-alpha.1":{"name":"@100terres/spread","version":"1.0.0-alpha.1","keywords":["conditional","helper","spread","util"],"author":{"name":"Mathieu Masy","email":"masy.mathieu@gmail.com"},"license":"MIT","_id":"@100terres/spread@1.0.0-alpha.1","maintainers":[{"name":"gab100terres","email":"gab@100terres.com"}],"homepage":"https://codeberg.org/100terres/spread","bugs":{"url":"https://codeberg.org/100terres/spread/issues"},"dist":{"shasum":"fe1323116c6062717c180e287c2797525904e26f","tarball":"https://registry.npmjs.org/@100terres/spread/-/spread-1.0.0-alpha.1.tgz","fileCount":5,"integrity":"sha512-yd9BVqtRexbAJVm15UC3HGQq4gddkrOFOhF6zjz7Io+e5tDi0MfFUZILM9Abs60yWGE2+v8OuR/Cvl39QSTWfA==","signatures":[{"sig":"MEUCIQDXzTojQNCppsag9vGmEai1jh//hVbuziahRCfdOmJnxQIgEbIQQGoLNEYmajLfrpShSMYmo/xWGv1iEX1IBBFdhzA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7946},"type":"module","_from":"file:100terres-spread-1.0.0-alpha.1.tgz","types":"./dist/spread.d.mts","$schema":"https://www.schemastore.org/package.json","exports":{".":"./dist/spread.mjs","./package.json":"./package.json"},"scripts":{"dev":"tsdown --watch","lint":"pnpm lint:oxlint && pnpm lint:eslint","test":"deno test","build":"tsdown","format":"oxfmt","lint:fix":"pnpm lint:oxlint:fix && pnpm lint:eslint:fix","lint:eslint":"eslint","lint:oxlint":"oxlint --type-aware --type-check","lint:eslint:fix":"eslint --fix","lint:oxlint:fix":"oxlint --fix --type-aware --type-check"},"_npmUser":{"name":"gab100terres","email":"gab@100terres.com"},"_resolved":"/tmp/6df061095505878842a6ac3e81056cd5/100terres-spread-1.0.0-alpha.1.tgz","_integrity":"sha512-yd9BVqtRexbAJVm15UC3HGQq4gddkrOFOhF6zjz7Io+e5tDi0MfFUZILM9Abs60yWGE2+v8OuR/Cvl39QSTWfA==","repository":{"url":"git+https://codeberg.org/100terres/spread.git","type":"git"},"_npmVersion":"11.8.0","description":"Ergonomic conditional spread.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"oxfmt":"^0.35.0","eslint":"^10.0.2","oxlint":"^1.50.0","tsdown":"^0.20.3","publint":"^0.3.17","git-cliff":"^2.12.0","typescript":"^6.0.0-beta","@std/expect":"npm:@jsr/std__expect@^1.0.17","@std/testing":"npm:@jsr/std__testing@^1.0.17","oxlint-tsgolint":"^0.15.0","@arethetypeswrong/core":"^0.18.2","@typescript/native-preview":"7.0.0-dev.20260226.1","eslint-plugin-package-json":"^0.89.1"},"_npmOperationalInternal":{"tmp":"tmp/spread_1.0.0-alpha.1_1772322711509_0.13679205049549803","host":"s3://npm-registry-packages-npm-production"}},"1.0.0-alpha.2":{"name":"@100terres/spread","version":"1.0.0-alpha.2","keywords":["conditional","helper","spread","util"],"author":{"name":"Mathieu Masy","email":"masy.mathieu@gmail.com"},"license":"MIT","_id":"@100terres/spread@1.0.0-alpha.2","maintainers":[{"name":"gab100terres","email":"gab@100terres.com"}],"homepage":"https://codeberg.org/100terres/spread","bugs":{"url":"https://codeberg.org/100terres/spread/issues"},"dist":{"shasum":"4169c592bbd5437ce939ab272a1186eb600c5010","tarball":"https://registry.npmjs.org/@100terres/spread/-/spread-1.0.0-alpha.2.tgz","fileCount":5,"integrity":"sha512-VKstOhk3cavXUU9l+urVEf5faemmwQWurTir6ufRpQ/TKtWi0qaO4xJ4bTvQ3KTXukP/CVZGArJYPesMK1nQLA==","signatures":[{"sig":"MEYCIQDPeI4FcPdE/gWRzSnJSmq/KVHEmHscrmC9Ge5b2cMKfwIhAPjsWjfJ4EHY7+Y2FuAVQCT+smGkO8Xc1yWcaF/bbuRe","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8000},"type":"module","_from":"file:100terres-spread-1.0.0-alpha.2.tgz","types":"./dist/spread.d.mts","$schema":"https://www.schemastore.org/package.json","exports":{".":"./dist/spread.mjs","./package.json":"./package.json"},"scripts":{"dev":"tsdown --watch","lint":"pnpm lint:oxlint && pnpm lint:eslint","test":"vitest","build":"tsdown","format":"oxfmt","lint:fix":"pnpm lint:oxlint:fix && pnpm lint:eslint:fix","lint:eslint":"eslint","lint:oxlint":"oxlint --type-aware --type-check","test:coverage":"vitest run --coverage","lint:eslint:fix":"eslint --fix","lint:oxlint:fix":"oxlint --fix --type-aware --type-check"},"_npmUser":{"name":"gab100terres","email":"gab@100terres.com"},"_resolved":"/tmp/976c547659d0881977a82bfc4949f5cc/100terres-spread-1.0.0-alpha.2.tgz","overrides":{"vite":"npm:rolldown-vite@7.3.1","rolldown":"1.0.0-rc.6"},"_integrity":"sha512-VKstOhk3cavXUU9l+urVEf5faemmwQWurTir6ufRpQ/TKtWi0qaO4xJ4bTvQ3KTXukP/CVZGArJYPesMK1nQLA==","repository":{"url":"git+https://codeberg.org/100terres/spread.git","type":"git"},"_npmVersion":"11.8.0","description":"Ergonomic conditional spread.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"oxfmt":"^0.35.0","eslint":"^10.0.2","oxlint":"^1.50.0","tsdown":"^0.20.3","vitest":"^4.0.18","publint":"^0.3.17","git-cliff":"^2.12.0","typescript":"^6.0.0-beta","oxlint-tsgolint":"^0.15.0","@arethetypeswrong/core":"^0.18.2","@typescript/native-preview":"7.0.0-dev.20260226.1","eslint-plugin-package-json":"^0.89.1"},"_npmOperationalInternal":{"tmp":"tmp/spread_1.0.0-alpha.2_1772330458739_0.9535856546188419","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"$schema":"https://www.schemastore.org/package.json","name":"@100terres/spread","version":"1.0.0","description":"Ergonomic conditional spread.","keywords":["conditional","helper","spread","util"],"homepage":"https://codeberg.org/100terres/spread","bugs":{"url":"https://codeberg.org/100terres/spread/issues"},"license":"MIT","author":{"name":"Mathieu Masy","email":"masy.mathieu@gmail.com"},"maintainers":[{"name":"gab100terres","email":"gab@100terres.com"}],"repository":{"type":"git","url":"git+https://codeberg.org/100terres/spread.git"},"type":"module","sideEffects":false,"types":"./dist/spread.d.mts","exports":{".":"./dist/spread.mjs","./package.json":"./package.json"},"publishConfig":{"access":"public"},"devDependencies":{"@arethetypeswrong/core":"^0.18.2","@typescript/native-preview":"7.0.0-dev.20260226.1","@vitest/coverage-v8":"4.0.18","eslint":"^10.0.2","eslint-plugin-package-json":"^0.89.1","git-cliff":"^2.12.0","oxfmt":"^0.35.0","oxlint":"^1.50.0","oxlint-tsgolint":"^0.15.0","publint":"^0.3.17","tsdown":"^0.20.3","typescript":"^6.0.0-beta","vitest":"^4.0.18"},"overrides":{"rolldown":"1.0.0-rc.6","vite":"npm:rolldown-vite@7.3.1"},"scripts":{"build":"tsdown","dev":"tsdown --watch","format":"oxfmt","lint":"pnpm lint:oxlint && pnpm lint:eslint","lint:eslint":"eslint","lint:eslint:fix":"eslint --fix","lint:fix":"pnpm lint:oxlint:fix && pnpm lint:eslint:fix","lint:oxlint":"oxlint --type-aware --type-check","lint:oxlint:fix":"oxlint --fix --type-aware --type-check","test":"vitest","test:coverage":"vitest run --coverage"},"_id":"@100terres/spread@1.0.0","_integrity":"sha512-Qf/mfXkxep4SfVX6L+lDLVEgsCV8Kg2kLt+ON4QFI56fAVs1j3cu0v9q9ygQEdC20TKtadnl63gGTyzXaHo1Ug==","_resolved":"/tmp/89d02080d170170b6fbb1c58b28f34ef/100terres-spread-1.0.0.tgz","_from":"file:100terres-spread-1.0.0.tgz","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-Qf/mfXkxep4SfVX6L+lDLVEgsCV8Kg2kLt+ON4QFI56fAVs1j3cu0v9q9ygQEdC20TKtadnl63gGTyzXaHo1Ug==","shasum":"01e92e0714416d38d0c3031ff0383ce1adfd512a","tarball":"https://registry.npmjs.org/@100terres/spread/-/spread-1.0.0.tgz","fileCount":5,"unpackedSize":8029,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCCUBj2C2jaS6WUPUqanaW7nG7MSC7xSjJYC2hAjn6wSQIhAIVYa2IMQMiNIJMjkN2xDTnnucP4ni2kKFgvO+VA1aCa"}]},"_npmUser":{"name":"gab100terres","email":"gab@100terres.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/spread_1.0.0_1772381112511_0.9603205517947351"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-27T04:37:52.081Z","modified":"2026-03-01T16:05:12.825Z","1.0.0-alpha.0":"2026-02-27T04:37:52.335Z","1.0.0-alpha.1":"2026-02-28T23:51:51.666Z","1.0.0-alpha.2":"2026-03-01T02:00:58.918Z","1.0.0":"2026-03-01T16:05:12.666Z"},"author":{"name":"Mathieu Masy","email":"masy.mathieu@gmail.com"},"license":"MIT","keywords":["conditional","helper","spread","util"],"description":"Ergonomic conditional spread.","maintainers":[{"name":"gab100terres","email":"gab@100terres.com"}],"readme":"# @100terres/spread\n\nErgonomic conditional spread.\n\n<p>\n  <a href=\"https://www.npmjs.com/package/@100terres/spread\">\n    <img\n      alt=\"@100terres/spread npm's version badge.\"\n      src=\"https://img.shields.io/npm/v/@100terres/spread.svg\"\n    />\n  </a>\n  <a href=\"LICENSE\">\n    <img\n      alt=\"@100terres/spread is released under the MIT license.\"\n      src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\n    />\n  </a>\n</p>\n\n## Why?\n\nInstead of using an if statement with `Object.assign`.\n\n```js\nfunction buildConfig(host, isSecure) {\n  const config = { host, protocol: \"http\" };\n\n  if (isSecure) {\n    Object.assign(config, { ssl: true, protocol: \"https\" });\n  }\n\n  return config;\n}\n```\n\nInstead of using a ternary operator wrapped in parentheses, which either returns\nthe object to spread or an empty object literal.\n\n```js\nconst buildConfig = (host, isSecure) => ({\n  host,\n  protocol: \"http\",\n  ...(isSecure ? { ssl: true, protocol: \"https\" } : {}),\n});\n```\n\nYou can use this easy-to-read utility.\n\n```js\nimport spread from \"@100terres/spread\";\n\nconst buildConfig = (host, isSecure) => ({\n  host,\n  protocol: \"http\",\n  ...spread({ ssl: true, protocol: \"https\" }).if(isSecure),\n});\n```\n\nSee the [usage section](#usage) for more examples.\n\n## Getting Started\n\nInstall `@100terres/spread` using the package manager of your choosing, import\nit and start using it!\n\n### Using npm\n\n```bash\nnpm install @100terres/spread\n```\n\n### Using pnpm\n\n```bash\npnpm add @100terres/spread\n```\n\n### Using yarn\n\n```bash\nyarn add @100terres/spread\n```\n\n## Usage\n\n### Overview\n\n| Examples                             | Description                                              |\n| ------------------------------------ | -------------------------------------------------------- |\n| `spread(object).if(condition)`       | Returns `object` when `condition` is truthy              |\n| `spread(object).unless(condition)`   | Returns `object` when `condition` is falsy               |\n| `spread(array).if(condition)`        | Returns `array` when `condition` is truthy               |\n| `spread(array).unless(condition)`    | Returns `array` when `condition` is falsy                |\n| `spread(callback).if(condition)`     | Returns value from `callback` when `condition` is truthy |\n| `spread(callback).unless(condition)` | Returns value from `callback` when `condition` is falsy  |\n\n**Disclaimer**\n\nIf the condition isn't met the function returns an empty array. Since an empty\narray can be spread into both objects and arrays, nothing is added in either\ncase.\n\n### With `if` method\n\nIt returns the object passed if the condition is truthy.\n\n```ts\nimport spread from \"@100terres/spread\";\n\n// { foo: \"bar\", baz: \"qux\" }\nconst a = {\n  foo: \"bar\",\n  ...spread({ baz: \"qux\" }).if(true),\n};\n\n// { foo: \"bar\" }\nconst b = {\n  foo: \"bar\",\n  ...spread({ baz: \"qux\" }).if(false),\n};\n```\n\n### With `unless` method\n\nIt returns the object passed if the condition is falsy. In this example, we'll\nuse an array, instead of an object.\n\n```ts\nimport spread from \"@100terres/spread\";\n\n// [ \"foo\", \"bar\" ]\nconst a = [\"foo\", \"bar\", ...spread([\"baz\", \"qux\"]).unless(true)];\n\n// [ \"foo\", \"bar\", \"baz\", \"qux\" ]\nconst a = [\"foo\", \"bar\", ...spread([\"baz\", \"qux\"]).unless(false)];\n```\n\n### With a callback\n\nIt conditionally invokes the callback.\n\n```js\nimport spread from \"@100terres/spread\";\n\n// It will also log \"Hello World!\"\n// { foo: \"bar\", baz: \"qux\" }\nconst a = {\n  foo: \"bar\",\n  ...spread(() => {\n    console.log(\"Hello World!\");\n\n    return { baz: \"qux\" };\n  }).if(true),\n};\n\n// It won’t log \"Hello World!\"\n// { foo: \"bar\" }\nconst b = {\n  foo: \"bar\",\n  ...spread(() => {\n    console.log(\"Hello World!\");\n\n    return { baz: \"qux\" };\n  }).if(false),\n};\n```\n\n### JSX example\n\nIt can increase the readability of your JSX code.\n\n```jsx\nimport spread from \"@100terres/spread\";\n\nconst SubmitButton = (props) => {\n  const { isSubmitting } = props;\n\n  return (\n    <button\n      type=\"submit\"\n      disabled={isSubmitting}\n      {...spread({ className: \"is-loading\" }).if(isSubmitting)}\n    >\n      Submit\n    </button>\n  );\n};\n```\n\n## License\n\nLicensed under the [MIT license](LICENSE).\n\n## Acknowledgements\n\n[Mathieu Mazy](https://github.com/TiuSh) is the original author of the utility\nitself.\n\nI've created, published, and maintained `@potloc/spready` package, but I no\nlonger work at Potloc, and I've lost access to the repo, so I've decided to\nbring it back to life under `@100terres/spread`.\n","readmeFilename":"README.md","homepage":"https://codeberg.org/100terres/spread","repository":{"type":"git","url":"git+https://codeberg.org/100terres/spread.git"},"bugs":{"url":"https://codeberg.org/100terres/spread/issues"}}