HTTPS SSH

Schnuller

[ˈʃnʊlɐ]

When it creates too much poop give it a Schnuller to feed it with noop.

Dedicated to Nika (Tim Pietruskys daughter)

npm Standard Version GitHub license GitHub issues

Travis branch bitHound bitHound Coveralls

<p align="center"><img width="300" src="https://cdn.rawgit.com/pixelass/schnuller/master/schnuller.svg" alt="logo"/></p>

  • Silence methods of an object
  • Create silenced copies
  • Create objects with noop methods

<!-- toc -->

<!-- tocstop -->

Installation

yarn add schnuller

Usage

Silence console.log

import Schnuller from 'schnuller'

window.console = new Schnuller(window.console, 'log')

console.log('Test') // => undefined

Silenced copies

import Schnuller from 'schnuller'

const foo = {
  hello(name = 'world') {
    return `Hello ${name}`
  },
  bye(name = 'world') {
    return `Bye ${name}`
  }
}
const bar = new Schnuller(foo, 'bye')
bar.hello() // => 'Hello World'
bar.bye() // => undefined
foo.hello() // => 'Hello World'
foo.bye() // => 'Bye World'

Keep non functions

import Schnuller from 'schnuller'

const foo = {
  hello(name = 'world') {
    return `Hello ${name}`
  },
  bye(name = 'world') {
    return `Bye ${name}`
  },
  ciao: 'ciao'
}
const bar = new Schnuller({}, 'bye', 'ciao')
bar.hello() // 'hello world'
bar.bye() // => undefined
bar.ciao() // => Error bye is not a function

Contributing

Testing

yarn test

© 2017 by Gregor Adams

Logo via onlinewebfonts