Sha256: 3ed1db4a30ffc14784a61b368aab4dd18cb943a7379f468cab5ced07f8535a5a

Contents?: true

Size: 970 Bytes

Versions: 100

Compression:

Stored size: 970 Bytes

Contents

/*!
 * Chai - addMethod utility
 * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
 * MIT Licensed
 */

/**
 * ### .addMethod (ctx, name, method)
 *
 * Adds a method to the prototype of an object.
 *
 *     utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
 *       var obj = utils.flag(this, 'object');
 *       new chai.Assertion(obj).to.be.equal(str);
 *     });
 *
 * Can also be accessed directly from `chai.Assertion`.
 *
 *     chai.Assertion.addMethod('foo', fn);
 *
 * Then can be used as any other assertion.
 *
 *     expect(fooStr).to.be.foo('bar');
 *
 * @param {Object} ctx object to which the method is added
 * @param {String} name of method to add
 * @param {Function} method function to be used for name
 * @name addMethod
 * @api public
 */

module.exports = function (ctx, name, method) {
  ctx[name] = function () {
    var result = method.apply(this, arguments);
    return result === undefined ? this : result;
  };
};

Version data entries

100 entries across 68 versions & 1 rubygems

Version Path
ende-0.4.25 vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.25 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.24 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.24 vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.23 vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.23 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.5.1 components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.22 vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.22 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.21 vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.21 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.5.0 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.20 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.19 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.18 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.17 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.4.16 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.3.13 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.3.12 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js
ende-0.3.11 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js