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 }
 

Dependents (1)

Package Sidebar

Install

npm i selfish-js

Weekly Downloads

10

Version

1.0.0

License

ISC

Last publish

Collaborators

  • fluffywaffles