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

@appolo/helpers

v8.0.2

Published

useful decorators

Downloads

628

Readme

Appolo Decorators

Build Status Dependencies status NPM version npm Downloads Known Vulnerabilities

useful decorators The cache will remove the oldest used item when reached max capacity

Installation:

npm install appolo-decorators --save

Delay

delay call method by given time in milliseconds

import { delay } from 'appolo-decorators';

class SomeClass {
    @delay(1000)
    method() {
    // ...
    }
}

Cache

cache method results using appolo-cache

options:

  • maxSize - max cache size default 1000

  • maxAge - optional set maximum age in ms of all cache items default unlimited

  • clone - clone the cache result default false

  • interval - set cache refresh interval

  • resolver - function to get the cache key by default the fist argument will be used as the cache key

  • multi - boolean if no resolver defined use all the arguments as key else use the first argument as key default false

  • peek - boolean use peek method instead of get default false

  • refresh - boolean refresh cache on half maxAge expire default false

import { cache } from 'appolo-decorators';

class SomeClass {
    private counter = 0;

    @cache()
    method() {
       return ++this.counter
    }
}

let someClass = new SomeClass();
someClass.method() // 1
someClass.method()// 1

Bind

bind method to class instance

import { bind } from 'appolo-decorators';

class SomeClass {
    @bind
    method() {
    // ...
    }
}

document.body.addEventListener('click', new SomeClass().method);

Debounce

debounce method using lodash debounce

import { debounce } from 'appolo-decorators';

class SomeClass {
    @debounce(1000,{trailing:true})
    method() {
    // ...
    }
}

Throttle

throttle method using lodash debounce

import { throttle } from 'appolo-decorators';

class SomeClass {
    @throttle(1000,{trailing:true})
    method() {
    // ...
    }
}

Memoize

memoize method using lodash debounce

import { memoize } from 'appolo-decorators';

class SomeClass {
    @memoize()
    method() {
    // ...
    }
}

Once

method will be called max n times and return last call result

import { once } from 'appolo-decorators';

class SomeClass {
    @once(2)
    method() {
    // ...
    }
}

Interval

set interval to method once called

import { interval } from 'appolo-decorators';

class SomeClass {
    @interval(100)
    method() {
    // ...
    }
}
//start the interval
new SomeClass().method()

Mixins

add prototype to class

import { mixins } from 'appolo-decorators';

@mixins(EventDispacher)
class SomeClass {

    method() {
    // ...
    }
}
new SomeClass().on("some event")

License

MIT