{"_id":"@adaskothebeast/http-params-processor-value-from-moment","_rev":"4-d144a67953a0a1ea5ea8003201259a7a","name":"@adaskothebeast/http-params-processor-value-from-moment","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-value-from-moment","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-value-from-moment@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"e11717ad82dd6fe193f677aa83a3430dd3809940","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-moment/-/http-params-processor-value-from-moment-10.0.0.tgz","fileCount":19,"integrity":"sha512-w9EWrFysLYJb+2LeayhGJ10Ua3w523MVxUlfBMNWrO167obH2oSaPmVHOkVfIwa3opqFGv+xh3/kCUVqn3WPCQ==","signatures":[{"sig":"MEUCICQ4H6QJ8CHmFLKyjms6uwAMzAQZSB10eKoTRFy6iwJbAiEAg9ucgP/NTHxoRwo3o2myuUHy8xFA0rlwrO1WPE5bmNU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31077},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"1e61d6323f67038b9af916e4f3d263a73fe76497","_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"_npmVersion":"11.6.2","description":"> Transform complex TypeScript objects into query parameters for Angular, Axios, Fetch, and more","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"peerDependencies":{"moment":"*","@adaskothebeast/http-params-processor-core":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-from-moment_10.0.0_1768077249553_0.31784359825241926","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-value-from-moment","version":"11.0.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-value-from-moment@11.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"c340a2b5f099fc556d44dfeeaee4a0fffdd3a85e","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-moment/-/http-params-processor-value-from-moment-11.0.0.tgz","fileCount":10,"integrity":"sha512-GHe2H3EZybf0RHcOzbCd6SBCGymZ3wtGsa7VhVuilB0D4BahwyGyHuJZc+zgLMHj3BUtvX0pGlvjocKjD9gW8A==","signatures":[{"sig":"MEUCIBLX8nyej6/lnz2/UTyXs1KwUdCPBYkfqDpJbClKhjH5AiEAybD2M6Hm0URuoXUdt62z+EcQuvN36Hsf9D+KbAwZsog=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-from-moment@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":42496},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9b361cc1-7d0c-40b9-9f2e-15721862a759"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-from-moment_11.0.0_1768758177966_0.0027388035853068704","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-value-from-moment","version":"11.1.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-value-from-moment@11.1.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"de78de2e232ac4c273100ffa9e2edb42dc7b8af1","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-moment/-/http-params-processor-value-from-moment-11.1.0.tgz","fileCount":10,"integrity":"sha512-hmGFOdzjmr0anE6rEgmZZys/NrNLy3OaAKE2/G5brTMHYfpJpuI8u4NFze9LX2Mxs8yjIQoOiZ7CiM15E6ypjg==","signatures":[{"sig":"MEQCH3Taoid9g2W1zhBdHpy+eyv6CWrGGYMbmL0OBeasB2UCIQD6HPpGSIp9cAFtC7ktTEHXVS4RoRs7V6PO++EwKgLoJg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-from-moment@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":42496},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9b361cc1-7d0c-40b9-9f2e-15721862a759"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-from-moment_11.1.0_1768758917451_0.9527229688263967","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-value-from-moment","version":"12.0.0","description":"Moment date and duration input strategies for HttpParamsProcessor value conversion.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","moment","momentjs","duration"],"license":"MIT","author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","type":"module","sideEffects":false,"main":"./index.cjs","module":"./index.js","types":"./index.d.ts","peerDependencies":{"@adaskothebeast/http-params-processor-core":"^12.0.0","moment":"^2.30.1"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"gitHead":"73d31a6c26a6f2819f6c98aabb36659532e4cdd0","_id":"@adaskothebeast/http-params-processor-value-from-moment@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-hZkPw4H3S1R2oBGVQyEpBxZdZRMeTKyVE8ppiRtAKK2ICdy3uZq5cMbtoFZCPN3YOPw2+S4yPK/6KoSsHTDGCw==","shasum":"faf1fdb5c14c5a70aa31816387bd7ce0a8aa819c","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-moment/-/http-params-processor-value-from-moment-12.0.0.tgz","fileCount":11,"unpackedSize":17420,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDg5vmOlz7tyRJ32CDtkWPB8c/J8SXqFsb7isl9zGhOxgIhAK5vp5EgWqxp+vrIEjEqByyCAL373Qjt4Sq1bVrSVCvj"}]},"_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"directories":{},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http-params-processor-value-from-moment_12.0.0_1785236243261_0.9510615613964142"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:34:09.476Z","modified":"2026-07-28T10:57:23.600Z","10.0.0":"2026-01-10T20:34:09.699Z","11.0.0":"2026-01-18T17:42:58.098Z","11.1.0":"2026-01-18T17:55:17.585Z","12.0.0":"2026-07-28T10:57:23.406Z"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"license":"MIT","homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"readme":"# ⏱️ @adaskothebeast/http-params-processor-value-from-moment\n\n**Moment.js input strategies for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor): normalize `Moment` instants and `moment.Duration` objects before they are serialized.**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-value-from-moment?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-moment)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nPeer dependencies: `core` and `moment` (`^2.30.1`). ESM + CJS. `sideEffects: false`.\n\n---\n\n## 📦 Install\n\n```bash\nnpm i @adaskothebeast/http-params-processor-value-from-moment @adaskothebeast/http-params-processor-core moment\n```\n\n`moment-timezone` is only needed if **your** code builds moments in named IANA zones (`moment.tz(...)`); the strategies themselves never touch zone data.\n\n---\n\n## 🎯 What it does\n\nThese are **value-from** strategies: the first half of the conversion pipeline. Each one normalizes a Moment type into a neutral shape and must be paired with a **value-to** strategy (`-value-to-iso`, `-value-to-nodatime`, `-value-to-unix-timestamp`, `-value-to-ms-timestamp`, `-value-to-date-fns`) through `createValueConverter`.\n\n| Class                             | Accepts                                             | Produces                                                                                        |\n| --------------------------------- | --------------------------------------------------- | ----------------------------------------------------------------------------------------------- |\n| `MomentDateValueFromStrategy`     | `Moment` (detected by `moment.isMoment`)            | `Date` (`value.toDate()`)                                                                       |\n| `MomentDurationValueFromStrategy` | `moment.Duration` (detected by `moment.isDuration`) | `DurationComponents` (`years`, `months`, `days`, `hours`, `minutes`, `seconds`, `milliseconds`) |\n\nDetection is exact and mutually exclusive: a `Moment` is never claimed by the duration strategy and vice versa, so both converters can be registered side by side.\n\n---\n\n## ⚡ Usage\n\n```ts\nimport { DefaultDateValueFromStrategy, ParamsProcessor, createValueConverter } from '@adaskothebeast/http-params-processor-core';\nimport { MomentDateValueFromStrategy, MomentDurationValueFromStrategy } from '@adaskothebeast/http-params-processor-value-from-moment';\nimport { IsoDateValueToStrategy, IsoDurationValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-iso';\nimport moment from 'moment';\n\nconst processor = new ParamsProcessor({\n  valueConverters: [\n    createValueConverter(new MomentDateValueFromStrategy(), new IsoDateValueToStrategy()),\n    createValueConverter(new MomentDurationValueFromStrategy(), new IsoDurationValueToStrategy()),\n    // keep native Dates working too\n    createValueConverter(new DefaultDateValueFromStrategy(), new IsoDateValueToStrategy()),\n  ],\n});\n\nprocessor.process('p', {\n  from: moment.utc('2024-01-15T10:30:00.000Z'),\n  window: moment.duration({ hours: 1, minutes: 30, seconds: 45 }),\n});\n// [['p.from', '2024-01-15T10:30:00.000Z'], ['p.window', 'PT1H30M45S']]\n```\n\n---\n\n## 🎛️ Options and configuration\n\nNeither strategy takes constructor options - both are stateless and safe to share between processors.\n\n**Zones and UTC mode collapse into an instant.** `toDate()` returns a native `Date`, so `moment.utc(...)`, `moment.parseZone(...)` and `moment.tz(..., 'Asia/Tokyo')` all serialize to the same moment in time; the offset itself is not carried. The paired writer decides the rendering (`-value-to-iso` always emits UTC with `Z`).\n\n**Moment normalizes durations for you.** Unlike Luxon and Day.js, `moment.duration` carries units on construction, so what you get out can differ from what you put in - see the table below.\n\n**Output format** is decided by the paired value-to strategy:\n\n```ts\nimport { MsTimestampValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-ms-timestamp';\n\ncreateValueConverter(new MomentDateValueFromStrategy(), new MsTimestampValueToStrategy());\n```\n\n---\n\n## 📤 Output examples\n\nPaired with `-value-to-iso`:\n\n| Value passed to `process`                            | Normalized shape                         | Serialized                 |\n| ---------------------------------------------------- | ---------------------------------------- | -------------------------- |\n| `moment.utc('2024-01-15T10:30:00.000Z')`             | `Date` (instant)                         | `2024-01-15T10:30:00.000Z` |\n| `moment.duration({ hours: 1, minutes: 30 })`         | `{ hours: 1, minutes: 30 }`              | `PT1H30M`                  |\n| `moment.duration({ minutes: 90 })`                   | `{ hours: 1, minutes: 30 }`              | `PT1H30M`                  |\n| `moment.duration({ months: 18 })`                    | `{ years: 1, months: 6 }`                | `P1Y6M`                    |\n| `moment.duration({ days: 45 })`                      | `{ months: 1, days: 14 }`                | `P1M14D`                   |\n| `moment.duration({ weeks: 2 })`                      | `{ days: 14 }`                           | `P14D`                     |\n| `moment.duration({ seconds: 1, milliseconds: 500 })` | `{ seconds: 1, milliseconds: 500 }`      | `PT1.5S`                   |\n| `moment.duration('PT1H30M45S')`                      | `{ hours: 1, minutes: 30, seconds: 45 }` | `PT1H30M45S`               |\n\n```text\np.from    = 2024-01-15T10:30:00.000Z\np.window  = PT1H30M45S\n```\n\n---\n\n## ⚠️ Edge cases\n\n- **Moment carries units, so values change shape.** `{ minutes: 90 }` comes back as 1 hour 30 minutes, `{ months: 18 }` as 1 year 6 months, and large day counts roll into months (`{ days: 45 }` becomes 1 month 14 days, using Moment's approximate 30.4-day month). Send `asDays()`/`asSeconds()` numbers instead if the backend needs the exact unit you authored.\n- **Weeks are folded into days.** Moment reports `moment.duration({ weeks: 2 }).days()` as `14`, and the strategy does not map a `weeks` field at all, so you get `P14D`, never `P2W`.\n- Zero components are converted to `undefined`, so `{ hours: 1 }` never emits `0` days or minutes, and `moment.duration(0)` normalizes to an empty object (`PT0S` with the ISO writer).\n- **Invalid moments still pass `canHandle`.** `moment('nope')` and `moment.invalid()` are `Moment` objects, so they are claimed and normalized to `Invalid Date`; `IsoDateValueToStrategy` then throws `RangeError: Invalid time value` (timestamp writers emit `NaN`). Guard with `.isValid()` before building your params object.\n- Fractional seconds are carried into the millisecond field (`{ seconds: 1.5 }` becomes `{ seconds: 1, milliseconds: 500 }`), which the ISO writer renders as `PT1.5S`.\n- Negative durations keep their sign per component, which produces non-standard output such as `PT-1H` - normalize with `.abs()` and send the sign separately if that matters.\n- `moment.Duration` values are not instants; never pair `MomentDurationValueFromStrategy` with a date writer such as `IsoDateValueToStrategy` - the converter always runs the paired writer, it does not re-check the shape.\n- Moment is in maintenance mode upstream; for new code prefer [`-value-from-luxon`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-luxon) or [`-value-from-dayjs`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-dayjs). Both can be registered next to this package during a gradual migration.\n\n---\n\n## 🔗 Related packages\n\n- Outputs: [`-value-to-iso`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-iso), [`-value-to-nodatime`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-nodatime), [`-value-to-unix-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-unix-timestamp), [`-value-to-ms-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-ms-timestamp), [`-value-to-date-fns`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-date-fns)\n- Other inputs: [`-value-from-luxon`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-luxon), [`-value-from-dayjs`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-dayjs), [`-value-from-js-joda`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-js-joda)\n- Engine: [`-core`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-core)\n\nFull matrix and adapter recipes: [main README](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor#readme).\n\n---\n\n## 📄 License\n\n[MIT](./LICENSE) © Adam Pluciński\n","readmeFilename":"README.md","description":"Moment date and duration input strategies for HttpParamsProcessor value conversion.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","moment","momentjs","duration"]}