npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

utils-compare

0.1.0

@jonschlinkert

npmHomeRepoSnykSocket
Downloads:84
$ npm install utils-compare
DailyWeeklyMonthlyYearly

utils-compare NPM version

Compare function that accepts two objects (a, b) and returns 1 if a >= b otherwise -1.

Quickstart

Open the command prompt in the root of your project and run the following command:

npm i utils-compare --save-dev

Usage

Example "globbing" utility, using the compare function to sort the result:

var compareFn = require('utils-compare');

var globFiles = function (src, compare_fn) {
  compare_fn = compareFn(compare_fn);
  src.map(function (path) {
    index += 1;
    return {
      index: index,
      path: path,
      content: grunt.file.read(path)
    };
  }).sort(compare_fn).map(function (foo) {
     // do stuff
  });
};

Author

  • twitter/jonschlinkert
  • github/jonschlinkert

License and Copyright

Licensed under the MIT License Copyright (c) Jon Schlinkert, contributors.