You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
496 B

4 years ago
  1. # `macro()`
  2. The macro method lets you register custom methods
  3. ```js
  4. collect().macro('uppercase', function () {
  5. return this.map(item => item.toUpperCase());
  6. });
  7. const collection = collect(['a', 'b', 'c']);
  8. collection.uppercase();
  9. collection.all();
  10. // ['A', 'B', 'C']
  11. ```
  12. > Note that the `macro` method returns `undefined`, and therefore it is not possible to use it within a chain of methods.
  13. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/macro.js)