npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

selfish-js

1.0.0 • Public • Published

Selfish

Build Status

It's a fast way to not function this. Wait, that doesn't make sense.

As a by-product of bypassing this, it also enables a sort of "self-syntax," although there's no reason you have to call it "self."

Uses object.create(null) by default, which is speedy and clean, but it can optionally accept a different "base." See below.

 
Selfish.simple(function (self) {
  self.a = 'a'
  self.b = function (c) {
    return self.a + ' ' + self.c
  }
}) // => { a: 'a', b: function (c) { ... } }
 
function AConstructor() {
  return function (a) {
    return Selfish.simple(function (self) {
      self.a = a
    })
  }
}
 
var A = Selfish.variadic.any([function (self, a, b, c) {
  self.a = a
  self.b = b
  self.c = c
}, 1, 'b', 'c'], AConstructor()) // => function (a) { ... }
 
A.a // => 1
A.b // => 'b'
A.c // => 'c'
 
A(7) // => { a: 7 }
 

install

npm i selfish-js

Downloadsweekly downloads

5

version

1.0.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability