Socket
Book a DemoInstallSign in
Socket

gimmie

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gimmie

The stupid iterator.

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

gimmie Build Status

The stupid iterator.

Getting Started

Install the module with: npm install gimmie

Documentation

gimmie( Any... ): Function

Accepts any number of values of any type and returns a function that yields each given value in turn when invoked multiple times.


    var gimmie = require('gimmie');

    var next = gimmie(3, 5, 7);

    console.log(next()); // 3
    console.log(next()); // 5
    console.log(next()); // 7
    console.log(next()); // undefined

gimmie( Function... ): Function

Accepts any number of functions and returns a function which masquerades as each given function in turn when invoked multiple times. Useful for mocking methods or injecting assertions in tests.


    var $ = require('jquery');
    var assert = require('assert');
    var gimmie = require('gimmie');

    var origAjax = $.ajax;

    $.ajax = gimmie(
        function (url) {
            assert.equal(url, 'http://google.com');
            return origAjax.apply($, arguments);
        },
        function (url) {
            assert.equal(url, 'http://github.com');
            return origAjax.apply($, arguments);
        }
    );

    $.ajax('http://google.com').then( ... ); // pass
    $.ajax('http://nodejs.org').then( ... ); // fail

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 0.1.0: Initial release.

License

Copyright (c) 2013 Shannon Moeller. Licensed under the MIT license.

FAQs

Package last updated on 26 Aug 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