Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-set

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-set - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

2

package.json
{
"name": "can-set",
"version": "0.5.2",
"version": "0.5.3",
"description": "Set logic for CanJS",

@@ -5,0 +5,0 @@ "main": "src/set.js",

@@ -296,1 +296,49 @@ var QUnit = require("steal-qunit");

});
test("paginated and sorted is subset (#17)", function(){
var algebra = new set.Algebra(
comparators.sort('sort'),
comparators.rangeInclusive('start','end')
);
var res = algebra.subset({start: 0, end: 100, sort: "name"},{start: 0, end: 100, sort: "name"});
equal(res, true, "parent:paginate+order child:paginate+order (same set)");
res = algebra.subset({start: 0, end: 100, sort: "name"},{start: 0, end: 100, sort: "age"});
equal(res, false, "parent:paginate+order child:paginate+order (different order)");
// REMOVE FROM THE parent
// parent:order
res = algebra.subset({start: 0, end: 100, sort: "name"},{sort: "name"});
equal(res, true, "parent:order child:paginate+order");
res = algebra.subset({sort: "name"},{sort: "name"});
equal(res, true, "parent:order child:order (same)");
res = algebra.subset({sort: "name"},{sort: "age"});
equal(res, true, "parent:order child:order (different)");
res = algebra.subset({start: 0, end: 100},{sort: "name"});
equal(res, true, "parent:order child:paginate");
res = algebra.subset({start: 0, end: 100, sort: "age"},{sort: "name"});
equal(res, true, "parent:order child:paginate+order");
// parent:paginate
res = algebra.subset({start: 0, end: 100, sort: "name"},{start: 0, end: 100});
equal(res, false, "parent:paginate child:paginate+order");
res = algebra.subset({sort: "name"},{start: 0, end: 100});
equal(res, false, "parent:paginate child:order (same)");
res = algebra.subset({start: 0, end: 100, sort: "name"},{});
equal(res, true, "parent:-- child:paginate+order");
res = algebra.subset({start: 10, end: 90, sort: "name"},{start: 0, end: 100, sort: "name"});
equal(res, true, "child in smaller range, same sort");
res = algebra.subset({start: 10, end: 90, sort: "name"},{start: 0, end: 100, sort: "age"});
equal(res, false, "child in smaller range, but different sort");
});

@@ -164,6 +164,19 @@ var h = require("./helpers");

// calls the operator method on different parts of the set.
evaluateOperator: function(operator, a, b, aOptions, bOptions) {
evaluateOperator: function(operator, a, b, aOptions, bOptions, evaluateOptions) {
aOptions = aOptions || {};
bOptions = bOptions || {};
evaluateOptions = h.extend({
evaluateWhere: operator,
evaluatePaginate: operator,
evaluateOrder: operator,
shouldEvaluatePaginate: function(aClauseProps, bClauseProps) {
return aClauseProps.enabled.paginate || bClauseProps.enabled.paginate;
},
shouldEvaluateOrder: function(aClauseProps, bClauseProps) {
return aClauseProps.enabled.order && compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined,{},{});
}
/* aClauseProps.enabled.order || bClauseProps.enabled.order */
}, evaluateOptions||{});
var aClauseProps = this.getClauseProperties(a, aOptions),

@@ -174,3 +187,3 @@ bClauseProps = this.getClauseProperties(b, bOptions),

var result = operator(aClauseProps.where, bClauseProps.where,
var result = evaluateOptions.evaluateWhere(aClauseProps.where, bClauseProps.where,
undefined, undefined, undefined, this.clauses.where, {});

@@ -181,7 +194,8 @@

// if success, and either has paginate props
if(result && (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate)) {
if(result && evaluateOptions.shouldEvaluatePaginate(aClauseProps,bClauseProps) ) {
// if they have an order, it has to be true for paginate to be valid
if(aClauseProps.enabled.order || bClauseProps.enabled.order) {
result = operator(aClauseProps.order, bClauseProps.order, undefined,
// this isn't true if a < b, a is paginated, and b is not.
if( evaluateOptions.shouldEvaluateOrder(aClauseProps,bClauseProps)) {
result = evaluateOptions.evaluateOrder(aClauseProps.order, bClauseProps.order, undefined,
undefined, undefined, {}, {});

@@ -193,3 +207,3 @@

if(result) {
result = operator(aClauseProps.paginate, bClauseProps.paginate,
result = evaluateOptions.evaluatePaginate(aClauseProps.paginate, bClauseProps.paginate,
undefined, undefined, undefined, this.clauses.paginate, {});

@@ -201,3 +215,3 @@

// if orders are the same keep order!
else if( result && aClauseProps.enabled.order && compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined,{},{}) ) {
else if( result && evaluateOptions.shouldEvaluateOrder(aClauseProps,bClauseProps) ) {

@@ -223,4 +237,4 @@ result = operator(aClauseProps.order, bClauseProps.order, undefined,

// if there is a paginate and an order, order has to be the same first.
if((aClauseProps.enabled.paginate || bClauseProps.enabled.paginate) &&
// if both have a paginate, make sure order is the same.
if( bClauseProps.enabled.paginate &&
(aClauseProps.enabled.order || bClauseProps.enabled.order)) {

@@ -227,0 +241,0 @@ // compare order clauses without any special comparators

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