Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

README.markdown 1.1 KiB

10 meses atrás
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. concat-map
  2. ==========
  3. Concatenative mapdashery.
  4. [![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map)
  5. [![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map)
  6. example
  7. =======
  8. ``` js
  9. var concatMap = require('concat-map');
  10. var xs = [ 1, 2, 3, 4, 5, 6 ];
  11. var ys = concatMap(xs, function (x) {
  12. return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
  13. });
  14. console.dir(ys);
  15. ```
  16. ***
  17. ```
  18. [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]
  19. ```
  20. methods
  21. =======
  22. ``` js
  23. var concatMap = require('concat-map')
  24. ```
  25. concatMap(xs, fn)
  26. -----------------
  27. Return an array of concatenated elements by calling `fn(x, i)` for each element
  28. `x` and each index `i` in the array `xs`.
  29. When `fn(x, i)` returns an array, its result will be concatenated with the
  30. result array. If `fn(x, i)` returns anything else, that value will be pushed
  31. onto the end of the result array.
  32. install
  33. =======
  34. With [npm](http://npmjs.org) do:
  35. ```
  36. npm install concat-map
  37. ```
  38. license
  39. =======
  40. MIT
  41. notes
  42. =====
  43. This module was written while sitting high above the ground in a tree.