Socket
Socket
Sign inDemoInstall

subset

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.1.3

4

api.md

@@ -159,3 +159,3 @@ # Subset API

```js
var notCoprime = $.seq2($.gcd, $.gt(1));
var notCoprime = $($.gcd, $.gt(1));
var primes = $.nubBy(notCoprime, $.range(2, 11)); // [ 2, 3, 5, 7, 11 ]

@@ -165,3 +165,3 @@ ```

Here the definition of equality is *a and b have common factors*.
Note the `range` and `seq2` functions from [interlude](https://github.com/clux/interlude).
Note the `range` and `$` functions from [interlude](https://github.com/clux/interlude).

@@ -168,0 +168,0 @@ ### $.group(xs) :: ys

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

0.1.3 / 2012-11-11
==================
* Code cleanups and better documentation
0.1.2 / 2012-10-24

@@ -2,0 +6,0 @@ ==================

@@ -5,3 +5,3 @@ {

"description": "Generalized set operations and comparisons in the style of Haskell",
"version": "0.1.2",
"version": "0.1.3",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -21,3 +21,3 @@ var $ = {};

if (typeof c === 'function') {
var c2 = c2 || 1;
c2 = c2 || 1;
return function (x, y) {

@@ -141,10 +141,7 @@ return c2 * (c(x) - c(y));

// nubBy builds up a list of unique (w.r.t. provided equality function) similarly to nub
$.nubBy = function (eq, xs) {
var result = []
, resLen = 0
, len = xs.length;
for (var i = 0; i < len; i += 1) {
var result = [];
for (var i = 0, len = xs.length; i < len; i += 1) {
var keep = true;
for (var j = 0; j < resLen; j += 1) {
for (var j = 0, resLen = result.length; j < resLen; j += 1) {
if (eq(result[j], xs[i])) {

@@ -157,3 +154,2 @@ keep = false;

result.push(xs[i]);
resLen += 1;
}

@@ -166,3 +162,3 @@ }

// elements by checking if current is not 'equal' to anything in the buildup
// http://jsperf.com/nubnubbytest1 => indexOf clearly beats calling $.nubBy($.eq2)
// http://jsperf.com/nubnubbytest1 => indexOf clearly beats calling $.nubBy(eq2)
$.nub = function (xs) {

@@ -196,6 +192,3 @@ var result = [];

$.unionBy = function (eq, xs, ys) {
var delBy = function (ys, y) {
return $.deleteBy(eq, ys, y);
};
return xs.concat(xs.reduce(delBy, $.nubBy(eq, ys)));
return xs.concat(xs.reduce($.deleteBy.bind(null, eq), $.nubBy(eq, ys)));
};

@@ -208,6 +201,3 @@

$.differenceBy = function (eq, xs, ys) {
var delBy = function (ys, y) {
return $.deleteBy(eq, ys, y);
};
return ys.reduce(delBy, xs.slice()); // reduce a copy
return ys.reduce($.deleteBy.bind(null, eq), xs.slice()); // reduce a copy
};

@@ -214,0 +204,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc