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

overridable

v0.0.1

Published

Make JavaScript overridable.

Downloads

1

Readme

Overridable

Make JavaScript overridable.

Introduction

JavaScript does not support overriding when we declare a function since JavaScript will cover the newer one with the older one. Thus, I made this package in order to enable this feature.

Usage

npm i overridable -S

overridable(): Overridable

Creates overridable object, includes

{
  // All of the function with different arguments
  functions: Array<Function>,
  // Add a function with a different arguments object
  add: Function<Function>,
  // If you add all the overrides, use this to get the final function
  result: Function;
};

add(fn: Function): Overridable

Add a function to overridable object.

overridable().add(() => {});

result(): Function

Returns the final function. If you add all the overrides, use this to get the final function.

const foo = overridable().add(() => {}).result();
foo();

Example

const overridable = require('overridable');

const foo = overridable()
  .add(a => Math.pow(a, 2))
  .add((a, b) => a * b)
  .add((a, b, c) => a + b + c)
  .result();

console.log(foo(3)); // 9
console.log(foo(2, 3)); // 6
console.log(foo(1, 2, 3)); // 6
console.log(foo(1, 2, 3, 4)); // Error

TODO

  • [ ] Unit test support
  • [ ] ES 2015 support
  • [x] NPM registry

Issues

I am very glad if you can find some issues in this project. If you do find something strange or some questions, please make a issue at https://github.com/lenconda/overridable/issues.

Contribute

Thank you for your interest in this project. You are welcomed to make contributions on it. However, before you starting your contribution work, please read the following advice:

  • Read the README first
  • Understand what changes you want to make
  • Look through the issue list and check if there's an issue to solve the same problem
  • Publish or/and redistribute this project should under MIT license

If you decide to write your code in this project, you can fork this project as your own repository, check out to a new branch, from the newest code at master branch. The new branch would be your work bench.

If you want to commit your changes, you are supposed to make an pull request, once you submit the request, the review process will start, if the code meets the requirements, the pull request will pass, and then your code will be in the project. If the request does not be passed, please contact [email protected] or [email protected].

License

MIT © Lenconda