Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
1234567891011121314151617181920212223242526272829
  1. var assert = require('assert')
  2. var chain = require('./index')
  3. console.log('testing...')
  4. var count = 0;
  5. chain(
  6. function(step){ count += step },
  7. function(step){ count += step },
  8. function(step){ count += step }
  9. )(1)
  10. assert.equal(count, 3, 'should chain calls')
  11. count = 0;
  12. chain(
  13. function(step){ count += step },
  14. null, undefined,
  15. function(step){ count += step }
  16. )(1)
  17. assert.equal(count, 2, 'should filter out null and undefined arguments')
  18. var fn = function(){}
  19. assert.equal(chain(fn, null), fn, 'should return the only function argument')
  20. console.log('done. tests pass!')