stubs

WebJar for stubs

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

stubs
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

stubs
WebJar for stubs
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/stephenplusplus/stubs

Download stubs

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/stubs/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>stubs</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/stubs/
implementation 'org.webjars.npm:stubs:3.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/stubs/
implementation ("org.webjars.npm:stubs:3.0.0")
'org.webjars.npm:stubs:jar:3.0.0'
<dependency org="org.webjars.npm" name="stubs" rev="3.0.0">
  <artifact name="stubs" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='stubs', version='3.0.0')
)
libraryDependencies += "org.webjars.npm" % "stubs" % "3.0.0"
[org.webjars.npm/stubs "3.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

stubs

It's a simple stubber.

About

For when you don't want to write the same thing over and over to cache a method and call an override, then revert it, and blah blah.

Use

$ npm install --save-dev stubs
var mylib = require('./lib/index.js')
var stubs = require('stubs')

// make it a noop
stubs(mylib, 'create')

// stub it out
stubs(mylib, 'create', function() {
  // calls this instead
})

// stub it out, but call the original first
stubs(mylib, 'create', { callthrough: true }, function() {
  // call original method, then call this
})

// use the stub for a while, then revert
stubs(mylib, 'create', { calls: 3 }, function() {
  // call this 3 times, then use the original method
})

API

stubs(object, method[[, opts], stub])

object

  • Type: Object

method

  • Type: String

Name of the method to stub.

opts

  • (optional)
  • Type: Object
opts.callthrough
  • (optional)
  • Type: Boolean
  • Default: false

Call the original method as well as the stub (if a stub is provided).

opts.calls
  • (optional)
  • Type: Number
  • Default: 0 (never revert)

Number of calls to allow the stub to receive until reverting to the original.

stub

  • (optional)
  • Type: Function
  • Default: function() {}

This method is called in place of the original method. If opts.callthrough is true, this method is called after the original method is called as well.

Versions

Version
3.0.0
1.1.2