🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

callable-klass

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callable-klass

Allows to create constructor functions ("classes") that returns callable instances

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Allows to create constructor functions ("classes") that returns callable instances.

Install with npm install callable-klass.

Example:

callable = require 'callable-klass'

Foo = callable class
  a: -> 1
  b: -> 2
  callable: -> @a() + @b()

# the `callable` function returns a new constructor that delegates to the original one
# and adds some magic. Foo still works as expected - its `prototype` is set to the original
# prototype, and the function's properties are still accessible.

foo = new Foo

# `foo` also works as expected, `foo.a()` and `foo.b()` works, but you can also call
# `foo()` directly, which delegates to the `callable` method

foo() # same as foo.callable(), returns 3

Keywords

callable

FAQs

Package last updated on 29 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts