# moment-immutable

> Make moment.js immutable

Latest version **1.0.9** (published 2021-02-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install moment-immutable
pnpm add moment-immutable
yarn add moment-immutable
bun add moment-immutable
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2021-02-14 |
| First published | 2017-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Smartin Nematronic |
| Maintainers | smartin85 |
| Keywords | momentjs, date, immutable, react |

## Links

- npm: https://www.npmjs.com/package/moment-immutable
- Repository: https://github.com/smartin85/moment-immutable
- Homepage: https://github.com/smartin85/moment-immutable#readme
- Issues: https://github.com/smartin85/moment-immutable/issues
- npm.io page: https://npm.io/package/moment-immutable

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2021-02-14
- 1.0.8 — 2021-02-14
- 1.0.7 — 2021-02-14
- 1.0.6 — 2021-02-14
- 1.0.5 — 2021-02-07
- 1.0.4 — 2017-12-08
- 1.0.2 — 2017-07-24
- 1.0.1 — 2017-02-16
- 1.0.0 — 2017-02-12

## README

# moment-immutable
[![MIT License][license-image]][license-url] 
[![npm version][npm-image]][npm-url]
[![npm downloads][downloads-image]][npm-url]
[![Build Status][azure-pipeline-image]][azure-pipeline-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]

[![Buy me a coffee][buy-me-a-coffee-image]][buy-me-a-coffee-url]

Make moment.js immutable (moments and durations)

## Getting Started
moment-immutable can be included in your app by different ways:

### Node.js
moment-immutable can be installed with npm and required into a script:
```
npm install --save moment-immutable
```
```js
var moment = require('moment');
require('moment-immutable');
```


### Browser
Just include the momentjs script, all your other moment.js-plugins and then the moment-immutable script:
```html
<script src="moment.js"></script>
<!-- All the other cool moment.js-plugins -->
<script src="moment-immutable.min.js"></script>
```

### Browser with Require.js
```js
define(["moment", "moment-immutable"], function (moment) {
    // you probably won´t need a reference to moment-immutable istself, so include it last
});
```

### Bower
```
bower install --save moment-immutable
```

## Working without moment-immutable

```js
var january1st = moment("2017-01-01");
var february1st = january1st.add(1, "month");

january1st.format();    // "2017-02-01T00:00:00+01:00" - damn
february1st.format();   // "2017-02-01T00:00:00+01:00"
```

## Working with moment-immutable
```js
var january1st = moment("2017-01-01");
var february1st = january1st.add(1, "month");

january1st.format();    // "2017-01-01T00:00:00+01:00" - yeah
february1st.format();   // "2017-02-01T00:00:00+01:00"
```

## Converting mutable methods of other plugins to immutable methods
By default moment-immutable is aware of all the mutable methods of moment.js (moments and durations) and moment-timezone.  
For converting mutable methods of other plugins to immutable methods you can do this:
```js
// If it is a method on moment-objects:
moment.immutable.addMomentMutable('period', 1); // makes the period-function immutable if it has at least 1 parameter

// If it is a method on a moment-duration-object
moment.immutable.addDurationMutable('set', 0);  // makes the set-function immutable
```

[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE

[npm-image]: https://badge.fury.io/js/moment-immutable.svg
[npm-url]: https://www.npmjs.com/package/moment-immutable

[downloads-image]: https://img.shields.io/npm/dt/moment-immutable.svg

[coveralls-image]: https://coveralls.io/repos/github/smartin85/moment-immutable/badge.svg
[coveralls-url]: https://coveralls.io/github/smartin85/moment-immutable

[snyk-image]: https://snyk.io/test/github/smartin85/moment-immutable/badge.svg
[snyk-url]: https://snyk.io/test/github/smartin85/moment-immutable

[azure-pipeline-image]: https://dev.azure.com/smartin85/moment-immutable/_apis/build/status/smartin85.moment-immutable?branchName=master
[azure-pipeline-url]: https://dev.azure.com/smartin85/moment-immutable/_build/latest?definitionId=2&branchName=master

[buy-me-a-coffee-image]: https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png
[buy-me-a-coffee-url]: https://www.buymeacoffee.com/smartin

---
_Source: https://npm.io/package/moment-immutable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
