save15

0.0.1 • Public • Published

moment-cache

Moment-cache is moment.js-depended tool to speed up your application.

During the app lifecycle we can call moment oftentimes. Every call is time. Time is performance. This tool will increase performance of your app by caching moment.js instances.

Why?

 
    import moment from 'moment';
    const cache = moment().cache()
    const dateString = '2016-08-24';
    const momentCalls = 99999;
 
    const check = (instance) => {
        let i = 0;
        const start = new Date;
        while (<= momentCalls) {
            instance(dateString);
            i++;
        }
        return new Date - start;
    }
 
    console.log(check(moment)) // ~1588 ms
    console.log(check(cache)) // ~35 ms
 

Syntax:

 
    const moment = import 'moment';
    const cache = moment().cache(options); // options is optional
    const date = cache('2016-06-28');
 

Options (optional):

  • storage: object where cache data is stored. By default - covert object behind the scenes.

Readme

Keywords

none

Package Sidebar

Install

npm i save15

Weekly Downloads

1

Version

0.0.1

License

none

Last publish

Collaborators

  • aqson