diff --git a/chain.js b/chain.js index 94b285a..5a6a5ec 100644 --- a/chain.js +++ b/chain.js @@ -30,11 +30,16 @@ Chain.prototype.toJSON = function () { extendChainPrototype() function extendChainPrototype (hideWarnings) { [ + 'every', + 'inverse', 'filter', + 'findKey', + 'find', 'forEach', 'mapKeys', 'map', - 'reduce' + 'reduce', + 'some' ].forEach(function (methodName) { var filename = dasherize(methodName) var filepath = path.join(__dirname, filename) diff --git a/package.json b/package.json index 35d5b2c..5352c6c 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,11 @@ }, "homepage": "https://github.com/tjmehta/object-loops", "dependencies": { - "101": "^1.2.0", + "101": "^1.6.1", "dasherize": "^2.0.0" }, "devDependencies": { + "camelize": "^1.0.0", "code": "^1.5.0", "lab": "^6.2.0", "nodemon": "^1.8.1", diff --git a/test/fixtures/all-method-names.js b/test/fixtures/all-method-names.js new file mode 100644 index 0000000..59edaf3 --- /dev/null +++ b/test/fixtures/all-method-names.js @@ -0,0 +1,15 @@ +var camelize = require('camelize') +var fs = require('fs') +var path = require('path') + +var jsFile = /^(.*)[.]js$/ +var ignoreFiles = /^(index|chain)[.]js$/ + +module.exports = fs.readdirSync(path.resolve(__dirname, '../..')) + .filter(function (filename) { + return jsFile.test(filename) && !ignoreFiles.test(filename) + }) + .map(function (filename) { + return jsFile.exec(filename)[1] + }) + .map(camelize) diff --git a/test/test-chain.js b/test/test-chain.js index ca63a56..bdd8e14 100644 --- a/test/test-chain.js +++ b/test/test-chain.js @@ -8,6 +8,7 @@ var describe = lab.describe var it = lab.it var expect = Code.expect +var allMethodNames = require('./fixtures/all-method-names.js') var chain = require('../chain') describe('chain', function () { @@ -26,6 +27,13 @@ describe('chain', function () { expect(output).to.deep.equal({ x: 1, y: 1 }) done() }) + it('should have all methods', function (done) { + var chainable = chain({}) + allMethodNames.forEach(function (name) { + expect(chainable[name]).to.be.a.function() + }) + done() + }) describe('errors', function () { it('should error if invoked w/ non-object', function (done) { chain([]) // works w/ arrays diff --git a/test/test-index.js b/test/test-index.js index 818462a..4c93682 100644 --- a/test/test-index.js +++ b/test/test-index.js @@ -10,6 +10,8 @@ var expect = Code.expect var noop = require('101/noop') +var allMethodNames = require('./fixtures/all-method-names.js') + describe('index', function () { describe('all methods', function () { before(function (done) { @@ -17,6 +19,12 @@ describe('index', function () { done() }) after(require('./fixtures/reset-object-prototype')) + it('should have all methods', function (done) { + allMethodNames.forEach(function (name) { + expect(Object[name]).to.be.a.function() + }) + done() + }) it('should iterate through all the key-value pairs in the object', function (done) { var obj = { foo: 1,