Comparing version 3.1.0 to 3.2.0
@@ -751,21 +751,21 @@ // Generated by CoffeeScript 1.10.0 | ||
this.is_subset = function(a, b) { | ||
this.is_subset = function(subset, superset) { | ||
/* Return whether `b` is a subset of `a`; this is true if each element of `b` is also | ||
an element of `a`. | ||
/* `is_subset subset, superset` returns whether `subset` is a subset of `superset`; this is true if each | ||
element of `subset` is also an element of `superset`. | ||
*/ | ||
var done, element, i, iterator, len, ref, type_of_a, type_of_b, value; | ||
type_of_a = CND.type_of(a); | ||
type_of_b = CND.type_of(b); | ||
if (type_of_a !== type_of_b) { | ||
throw new Error("expected two arguments of same type, got " + type_of_a + " and " + type_of_b); | ||
var done, element, i, iterator, len, ref, type_of_sub, type_of_super, value; | ||
type_of_sub = CND.type_of(subset); | ||
type_of_super = CND.type_of(superset); | ||
if (type_of_sub !== type_of_super) { | ||
throw new Error("expected two arguments of same type, got " + type_of_sub + " and " + type_of_super); | ||
} | ||
switch (type_of_a) { | ||
switch (type_of_sub) { | ||
case 'list': | ||
if (!(b.length <= a.length)) { | ||
if (!(subset.length <= superset.length)) { | ||
return false; | ||
} | ||
for (i = 0, len = b.length; i < len; i++) { | ||
element = b[i]; | ||
if (indexOf.call(a, element) < 0) { | ||
for (i = 0, len = subset.length; i < len; i++) { | ||
element = subset[i]; | ||
if (indexOf.call(superset, element) < 0) { | ||
return false; | ||
@@ -776,6 +776,6 @@ } | ||
case 'set': | ||
if (!(b.size <= a.size)) { | ||
if (!(subset.size <= superset.size)) { | ||
return false; | ||
} | ||
iterator = b.values(); | ||
iterator = subset.values(); | ||
while (true) { | ||
@@ -786,3 +786,3 @@ ref = iterator.next(), value = ref.value, done = ref.done; | ||
} | ||
if (!a.has(value)) { | ||
if (!superset.has(value)) { | ||
return false; | ||
@@ -793,3 +793,3 @@ } | ||
default: | ||
throw new Error("expected lists or sets, got " + type_of_a + " and " + type_of_b); | ||
throw new Error("expected lists or sets, got " + type_of_sub + " and " + type_of_super); | ||
} | ||
@@ -796,0 +796,0 @@ return null; |
@@ -190,15 +190,15 @@ // Generated by CoffeeScript 1.10.0 | ||
this['is_subset'] = function(T) { | ||
T.eq(false, CND.is_subset(Array.from('abcd'), Array.from('abcde'))); | ||
T.eq(false, CND.is_subset(Array.from('abcd'), Array.from('abcx'))); | ||
T.eq(false, CND.is_subset([], Array.from('abcd'))); | ||
T.eq(false, CND.is_subset(Array.from('abcde'), Array.from('abcd'))); | ||
T.eq(false, CND.is_subset(Array.from('abcx'), Array.from('abcd'))); | ||
T.eq(false, CND.is_subset(Array.from('abcd'), [])); | ||
T.eq(true, CND.is_subset(Array.from('abcd'), Array.from('abcd'))); | ||
T.eq(true, CND.is_subset(Array.from('abcd'), Array.from('abc'))); | ||
T.eq(true, CND.is_subset(Array.from('abcd'), [])); | ||
T.eq(true, CND.is_subset(Array.from([]), [])); | ||
T.eq(false, CND.is_subset(new Set('abcd'), new Set('abcde'))); | ||
T.eq(false, CND.is_subset(new Set('abcd'), new Set('abcx'))); | ||
T.eq(false, CND.is_subset(new Set(), new Set('abcx'))); | ||
T.eq(true, CND.is_subset(Array.from('abc'), Array.from('abcd'))); | ||
T.eq(true, CND.is_subset([], Array.from('abcd'))); | ||
T.eq(true, CND.is_subset([], Array.from([]))); | ||
T.eq(false, CND.is_subset(new Set('abcde'), new Set('abcd'))); | ||
T.eq(false, CND.is_subset(new Set('abcx'), new Set('abcd'))); | ||
T.eq(false, CND.is_subset(new Set('abcx'), new Set())); | ||
T.eq(true, CND.is_subset(new Set('abcd'), new Set('abcd'))); | ||
T.eq(true, CND.is_subset(new Set('abcd'), new Set('abc'))); | ||
T.eq(true, CND.is_subset(new Set('abcd'), new Set())); | ||
T.eq(true, CND.is_subset(new Set('abc'), new Set('abcd'))); | ||
T.eq(true, CND.is_subset(new Set(), new Set('abcd'))); | ||
return T.eq(true, CND.is_subset(new Set(), new Set())); | ||
@@ -205,0 +205,0 @@ }; |
{ | ||
"name": "cnd", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "a grab-bag NodeJS package mainly for functionalities that used to live in coffeenode-trm, coffeenode-bitsnpieces, and coffeenode-types", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
269749