npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

immoment

v0.1.4

Published

Immutable Moment

Downloads

92

Readme

Immoment = Immutable Moment

npm install Build Status Known Vulnerabilities Downloads License

It works just like Moment.js but without surprises.

This project is very young and is a work in progress.

The 0.1 version supports some methods on the immoment object itself, but durations are not encapsulated yet. Still it is already useful for simple use cases.

For example, in Moment when you write:

var january1 = moment('2015-01-01');
var february1 = january1.add(1, 'months');
var march1 = january1.add(2, 'months');

you may be surprised that march1 is now set to the April Fools' Day.

Using Immoment after running the above code march1 would be March 1 which some people may find somewhat less surprising.

Roadmap

  • The 0.0.x is the first working experiment
  • The 0.1.x has methods like immoment.min() working
  • The 0.2.x will have durations properly encapsulated
  • ...

Contact me with any suggestions.

Size

The minified version of Immoment is less than 0.5kB and less than 0.25kB gzipped.

Performance

The performane of Immoment is around 97% of the performance of Moment for a typical use case. See benchmarks:

If your programs do anything else besides calling methods on Moment objects then you are not likely to see even that 3% hit.

Installation

Install to use in your Node project, updating the dependencies in package.json:

npm install immoment --save

Usage

To use it in place of moment:

var moment = require('immoment');

Usage in browser

You need to load both moment.js and immoment.js (in that order). Example with CDN:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdn.rawgit.com/rsp/node-immoment/v0.1.1/immoment.min.js"></script>

See the latest version of Moment on:

And the latest version of Immoment on:

Example

var immoment = require('immoment');
var moment = require('moment');

var mJan1 = moment('2015-01-01');
var mFeb1 = mJan1.add(1, 'months');

var iJan1 = immoment('2015-01-01');
var iFeb1 = iJan1.add(1, 'months');

console.log('moment - Jan1 is ' + mJan1.format('MMM D'));
console.log('moment - Feb1 is ' + mFeb1.format('MMM D'));

console.log('immoment - Jan1 is ' + iJan1.format('MMM D'));
console.log('immoment - Feb1 is ' + iFeb1.format('MMM D'));

It outputs:

moment - Jan1 is Feb 1
moment - Feb1 is Feb 1
immoment - Jan1 is Jan 1
immoment - Feb1 is Feb 1

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski Follow on GitHub Follow on Twitter

License

This is free software released under the Expat (MIT) License.

It is a permissive, non-copyleft, GPL-compatible license that complies with:

See LICENSE.md for details.