New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

comparator-factory-factory

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comparator-factory-factory - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

index.min.js

2

index.iife.min.js

@@ -1,1 +0,1 @@

var comparatorFactoryFactory=function(){"use strict";function u(n,r){var t=r?(n.selector||function(r){{if("function"!=typeof r)throw new Error("comparison key must be a function");return function(n){try{return r(n)}catch(n){}}}})(r):function(n){return n},u=function(n){if(!n||!n.length)return;var e=n.map(function(n){var r=n[0],t=n[1],u="function"==typeof r?r:r!=r?function(n){return n!=n}:function(n){return n===r},e="last"===t?1:-1;return function(n,r){return u(n)?u(r)?0:e:u(r)?-e:void 0}});return function(n,r){for(var t,u=0;u<e.length&&void 0===(t=e[u](n,r));++u);return t}}(n.specials),e=n.collator,o=e&&"function"==typeof e.compare?e:Intl.Collator(e&&e.locales,e),i=function(n,r){var t;return n===r?0:void 0!==(t=u&&u(n,r))?t:void 0===n?-1:void 0===r?1:null===n?-1:null===r?1:n!=n?r!=r?0:-1:r!=r?1:Array.isArray(n)&&Array.isArray(r)?function(n,r,t){for(var u=0,e=Math.min(n.length,r.length),o=0;o<e&&!(u=t(n[o],r[o]));++o);return u||t(n.length,r.length)}(n,r,i):"string"==typeof n||"string"==typeof r?o.compare(String(n),String(r)):n<r?-1:1};return function(n,r){return i(t(n),t(r))}}return function(n){return function(){return function r(u){return u.reversed=function(n){return void 0===n&&(n=!0),n?r(function(n,r){var t=u(n,r);return t&&-t}):u},u.or=function(t){return r(function(n,r){return u(n,r)||t(n,r)})},u}(function(n,r){for(var e=[],t=0;t<r.length;++t)e.push(u(n,r[t]));switch(e.length){case 0:return u(n);case 1:return e[0];case 2:return function(n,r){return e[0](n,r)||e[1](n,r)};case 3:return function(n,r){return e[0](n,r)||e[1](n,r)||e[2](n,r)};default:return function(n,r){for(var t=0,u=0;u<e.length&&0===(t=e[u](n,r));++u);return t}}}(n||{},arguments))}}}();
var comparatorFactoryFactory=function(){"use strict";function n(n,r){var t=r?(n.selector||function(n){if("function"!=typeof n)throw new Error("comparison key must be a function");return function(r){try{return n(r)}catch(n){}}})(r):function(n){return n},u=function(n){if(!n||!n.length)return;var r=n.map(function(n){var r=n[0],t=n[1],u="function"==typeof r?r:r!=r?function(n){return n!=n}:function(n){return n===r},e="last"===t?1:-1;return function(n,r){return u(n)?u(r)?0:e:u(r)?-e:void 0}});return function(n,t){for(var u,e=0;e<r.length&&void 0===(u=r[e](n,t));++e);return u}}(n.specials),e=n.collator,o=e&&"function"==typeof e.compare?e:Intl.Collator(e&&e.locales,e),i=function(n,r){var t;return n===r?0:void 0!==(t=u&&u(n,r))?t:void 0===n?-1:void 0===r?1:null===n?-1:null===r?1:n!=n?r!=r?0:-1:r!=r?1:Array.isArray(n)&&Array.isArray(r)?function(n,r,t){for(var u=0,e=Math.min(n.length,r.length),o=0;o<e&&!(u=t(n[o],r[o]));++o);return u||t(n.length,r.length)}(n,r,i):"string"==typeof n||"string"==typeof r?o.compare(String(n),String(r)):n<r?-1:1};return function(n,r){return i(t(n),t(r))}}return function(r){return function(){return function n(r){return r.reversed=function(t){return void 0===t&&(t=!0),t?n(function(n,t){var u=r(n,t);return u&&-u}):r},r.or=function(t){return n(function(n,u){return r(n,u)||t(n,u)})},r}(function(r,t){for(var u=[],e=0;e<t.length;++e)u.push(n(r,t[e]));switch(u.length){case 0:return n(r);case 1:return u[0];case 2:return function(n,r){return u[0](n,r)||u[1](n,r)};case 3:return function(n,r){return u[0](n,r)||u[1](n,r)||u[2](n,r)};default:return function(n,r){for(var t=0,e=0;e<u.length&&0===(t=u[e](n,r));++e);return t}}}(r||{},arguments))}}}();
{
"name": "comparator-factory-factory",
"version": "0.1.0",
"version": "0.2.0",
"description": "Create comparison functions to be used for sorting arrays.",
"main": "index",
"module": "index.mjs",
"main": "index.min",
"module": "index.min.mjs",
"types": "index.d.ts",

@@ -12,3 +12,5 @@ "jsdelivr": "index.iife.min.js",

"index.js",
"index.min.js",
"index.mjs",
"index.min.mjs",
"index.d.ts",

@@ -32,7 +34,7 @@ "index.iife.min.js",

"clean": "rimraf index.js index.mjs index.d.ts index.iife.min.js coverage",
"build": "npm run clean && npm run build:es && npm run build:cjs && npm run build:iife && npm test",
"build:es": "tsc -p . && node -e \"require('fs').renameSync('index.js','index.mjs')\"",
"build:cjs": "rollup -i index.mjs -f cjs -o index.js",
"build": "npm run clean && npm run build:mjs && npm run build:cjs && npm run build:iife && npm test",
"build:mjs": "tsc -p . && node -e \"require('fs').renameSync('index.js','index.mjs')\" && uglifyjs -m toplevel=true -c join_vars=true -o index.min.mjs index.mjs",
"build:cjs": "rollup -i index.mjs -f cjs -o index.js && uglifyjs -m toplevel=true -c join_vars=true -o index.min.js index.js",
"build:iife": "rollup -i index.mjs -f iife -n comparatorFactoryFactory | uglifyjs -m -c join_vars=true -o index.iife.min.js",
"test": "jest"
"test": "jest && node verify/commonjs.js && node --experimental-modules verify/esmodule.mjs"
},

@@ -48,3 +50,3 @@ "devDependencies": {

"typescript": "^2.8.3",
"uglify-js": "^3.3.22"
"uglify-es": "^3.3.9"
},

@@ -51,0 +53,0 @@ "jest": {

# comparator-factory-factory
Create comparison functions to be used for sorting arrays.
Create comparison functions to be used for sorting arrays.
This is a dedicated tiny library, not aiming at a [framework](http://discuss.joelonsoftware.com/default.asp?joel.3.219431.12).

@@ -8,2 +9,3 @@

* Available for both Node.js and browsers (including IE 11)
* Function-based comparison value selection

@@ -20,3 +22,3 @@ * Property-path-based comparison value selection can be implemented easily

Creating not a comparison function directly but a comparison function factory that may be shared
* Lightweight (< 1kb gzipped IIFE)
* Lightweight (~1.6kB minified, ~0.7kB gzipped)

@@ -36,3 +38,2 @@ ## Install

const comparing = comparatorFactoryFactory();
[].sort(comparing());

@@ -44,3 +45,3 @@ ```

```html
<script src="https://cdn.jsdelivr.net/npm/comparator-factory-factory@0.1.0"></script>
<script src="https://cdn.jsdelivr.net/npm/comparator-factory-factory@0.2.0"></script>
<script>

@@ -52,3 +53,14 @@ const comparing = comparatorFactoryFactory();

or for [modern browsers](https://caniuse.com/#feat=es6-module):
```html
<script type="module">
import comparatorFactoryFactory from "https://cdn.jsdelivr.net/npm/comparator-factory-factory@0.2.0/index.min.mjs";
const comparing = comparatorFactoryFactory();
[].sort(comparing());
</script>
```
## Usage & Examples

@@ -199,3 +211,3 @@

Following code is a property-path-based comparison example using [lodash/get](https://lodash.com/docs/#get). (FYI, [there are so many similar modules...](http://www.npmtrends.com/lodash-vs-underscore-vs-get-value-vs-dot-prop-vs-object-path-vs-pathval-vs-object-resolve-path-vs-fast-get-vs-selectn)).
Following code is a property-path-based comparison example using [lodash/get](https://lodash.com/docs/#get). (BTW, there are so many [similar modules](http://www.npmtrends.com/lodash-vs-underscore-vs-get-value-vs-dot-prop-vs-object-path-vs-pathval-vs-object-resolve-path-vs-fast-get-vs-selectn).)

@@ -202,0 +214,0 @@ ```javascript

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc