diff --git a/dist/amd/src/clause.js b/dist/amd/src/clause.js new file mode 100644 index 0000000..d6cc808 --- /dev/null +++ b/dist/amd/src/clause.js @@ -0,0 +1,27 @@ +/*can-set@1.5.2#src/clause*/ +define([ + 'require', + 'exports', + 'module', + 'can-util/js/assign', + 'can-util/js/each' +], function (require, exports, module) { + 'use strict'; + var assign = require('can-util/js/assign'); + var each = require('can-util/js/each'); + var clause = {}; + module.exports = clause; + clause.TYPES = [ + 'where', + 'order', + 'paginate', + 'id' + ]; + each(clause.TYPES, function (type) { + var className = type.charAt(0).toUpperCase() + type.substr(1); + clause[className] = function (compare) { + assign(this, compare); + }; + clause[className].type = type; + }); +}); \ No newline at end of file diff --git a/dist/amd/src/compare.js b/dist/amd/src/compare.js new file mode 100644 index 0000000..6f6e21f --- /dev/null +++ b/dist/amd/src/compare.js @@ -0,0 +1,480 @@ +/*can-set@1.5.2#src/compare*/ +define([ + 'require', + 'exports', + 'module', + './helpers', + 'can-util/js/assign', + 'can-util/js/each', + 'can-util/js/make-array' +], function (require, exports, module) { + 'use strict'; + var h = require('./helpers'); + var assign = require('can-util/js/assign'); + var each = require('can-util/js/each'); + var makeArray = require('can-util/js/make-array'); + var compareHelpers; + var loop = function (a, b, aParent, bParent, prop, compares, options) { + var checks = options.checks; + for (var i = 0; i < checks.length; i++) { + var res = checks[i](a, b, aParent, bParent, prop, compares || {}, options); + if (res !== undefined) { + return res; + } + } + return options['default']; + }; + var addIntersectedPropertyToResult = function (a, b, aParent, bParent, prop, compares, options) { + var subsetCheck; + if (!(prop in aParent)) { + subsetCheck = 'subsetB'; + } else if (prop in bParent) { + return false; + } + if (!(prop in bParent)) { + subsetCheck = 'subsetA'; + } + if (subsetCheck === 'subsetB') { + options.result[prop] = b; + } else { + options.result[prop] = a; + } + return undefined; + }; + var addToResult = function (fn, name) { + return function (a, b, aParent, bParent, prop, compares, options) { + var res = fn.apply(this, arguments); + if (res === true) { + if (prop !== undefined && !(prop in options.result)) { + options.result[prop] = a; + } + return true; + } else { + return res; + } + }; + }; + var addResultsToNewObject = function (fn, name) { + return function (a, b, aParent, bParent, prop, compares, options) { + var existingResult = options.result; + options.result = {}; + var res = fn.apply(this, arguments); + if (res) { + if (prop !== undefined) { + existingResult[prop] = options.result; + } else { + assign(existingResult, options.result); + } + } + options.result = existingResult; + return res; + }; + }; + module.exports = compareHelpers = { + equal: function (a, b, aParent, bParent, prop, compares, options) { + options.checks = [ + compareHelpers.equalComparesType, + compareHelpers.equalBasicTypes, + compareHelpers.equalArrayLike, + compareHelpers.equalObject + ]; + options['default'] = false; + return loop(a, b, aParent, bParent, prop, compares, options); + }, + equalComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return compareResult; + } else if (compareResult && typeof compareResult === 'object') { + if ('intersection' in compareResult && !('difference' in compareResult)) { + var reverseResult = compares(b, a, bParent, aParent, prop, options); + return 'intersection' in reverseResult && !('difference' in reverseResult); + } + return false; + } + return compareResult; + } + }, + equalBasicTypes: function (a, b, aParent, bParent, prop, compares, options) { + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); + } + if (options.deep === -1) { + return typeof a === 'object' || a === b; + } + if (typeof a !== typeof b || Array.isArray(a) !== Array.isArray(b)) { + return false; + } + if (a === b) { + return true; + } + }, + equalArrayLike: function (a, b, aParent, bParent, prop, compares, options) { + if (Array.isArray(a) && Array.isArray(b)) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + var compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!loop(a[i], b[i], a, b, i, compare, options)) { + return false; + } + } + return true; + } + }, + equalObject: function (a, b, aParent, bParent, parentProp, compares, options) { + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + var bCopy = assign({}, b); + if (options.deep === false) { + options.deep = -1; + } + for (var prop in a) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a[prop], b[prop], a, b, prop, compare, options)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !loop(undefined, b[prop], a, b, prop, compares[prop], options)) { + return false; + } + } + return true; + } + }, + subset: function (a, b, aParent, bParent, prop, compares, options) { + options.checks = [ + compareHelpers.subsetComparesType, + compareHelpers.equalBasicTypes, + compareHelpers.equalArrayLike, + compareHelpers.subsetObject + ]; + options.getSubsets = []; + options['default'] = false; + return loop(a, b, aParent, bParent, prop, compares, options); + }, + subsetObject: function (a, b, aParent, bParent, parentProp, compares, options) { + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + return h.eachInUnique(a, function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options) && prop in bParent) { + return false; + } + }, b, function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options)) { + return false; + } + }, true); + } + }, + subsetComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return compareResult; + } else if (compareResult && typeof compareResult === 'object') { + if (compareResult.getSubset) { + if (h.indexOf.call(options.getSubsets, compareResult.getSubset) === -1) { + options.getSubsets.push(compareResult.getSubset); + } + } + if (compareResult.intersection === h.ignoreType || compareResult.difference === h.ignoreType) { + return true; + } + if ('intersection' in compareResult && !('difference' in compareResult)) { + var reverseResult = compares(b, a, bParent, aParent, prop, options); + return 'intersection' in reverseResult; + } + return false; + } + return compareResult; + } + }, + properSupersetObject: function (a, b, aParent, bParent, parentProp, compares, options) { + var bType = typeof b; + var hasAdditionalProp = false; + if (bType === 'object' || bType === 'function') { + var aCopy = assign({}, a); + if (options.deep === false) { + options.deep = -1; + } + for (var prop in b) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + var compareResult = loop(a[prop], b[prop], a, b, prop, compare, options); + if (compareResult === h.ignoreType) { + } else if (!(prop in a) || options.performedDifference) { + hasAdditionalProp = true; + } else if (!compareResult) { + return false; + } + delete aCopy[prop]; + } + for (prop in aCopy) { + if (compares[prop] === undefined || !loop(a[prop], undefined, a, b, prop, compares[prop], options)) { + return false; + } + } + return hasAdditionalProp; + } + }, + properSubsetComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return compareResult; + } else if (compareResult && typeof compareResult === 'object') { + if ('intersection' in compareResult && !('difference' in compareResult)) { + var reverseResult = compares(b, a, bParent, aParent, prop, options); + return 'intersection' in reverseResult && 'difference' in reverseResult; + } + return false; + } + return compareResult; + } + }, + difference: function (a, b, aParent, bParent, prop, compares, options) { + options.result = {}; + options.performedDifference = 0; + options.checks = [ + compareHelpers.differenceComparesType, + addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'), + addToResult(compareHelpers.equalArrayLike, 'equalArrayLike'), + addToResult(compareHelpers.properSupersetObject, 'properSubsetObject') + ]; + options['default'] = true; + var res = loop(a, b, aParent, bParent, prop, compares, options); + if (res === true && options.performedDifference) { + return options.result; + } + return res; + }, + differenceComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + if (compareResult === true) { + options.result[prop] = a; + return true; + } else { + return compareResult; + } + } else if (compareResult && typeof compareResult === 'object') { + if ('difference' in compareResult) { + if (compareResult.difference === h.ignoreType) { + return h.ignoreType; + } else if (compareResult.difference != null) { + options.result[prop] = compareResult.difference; + options.performedDifference++; + return true; + } else { + return true; + } + } else { + if (compareHelpers.equalComparesType.apply(this, arguments)) { + options.performedDifference++; + options.result[prop] = compareResult.union; + } else { + return false; + } + } + } + } + }, + union: function (a, b, aParent, bParent, prop, compares, options) { + options.result = {}; + options.performedUnion = 0; + options.checks = [ + compareHelpers.unionComparesType, + addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'), + addToResult(compareHelpers.unionArrayLike, 'unionArrayLike'), + addResultsToNewObject(compareHelpers.unionObject, 'unionObject') + ]; + options.getUnions = []; + options['default'] = false; + var res = loop(a, b, aParent, bParent, prop, compares, options); + if (res === true) { + return options.result; + } + return false; + }, + unionComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + if (compareResult === true) { + options.result[prop] = a; + return true; + } else { + return compareResult; + } + } else if (compareResult && typeof compareResult === 'object') { + if (compareResult.getUnion) { + if (h.indexOf.call(options.getUnions, compareResult.getUnion) === -1) { + options.getUnions.push(compareResult.getUnion); + } + } + if ('union' in compareResult) { + if (compareResult.union === h.ignoreType) { + return compareResult.union; + } + if (compareResult.union !== undefined) { + options.result[prop] = compareResult.union; + } + options.performedUnion++; + return true; + } + } + } + }, + unionObject: function (a, b, aParent, bParent, prop, compares, options) { + var subsetCompare = function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options)) { + var subsetCheck; + if (!(prop in aParent)) { + subsetCheck = 'subsetB'; + } + if (!(prop in bParent)) { + subsetCheck = 'subsetA'; + } + if (subsetCheck) { + if (!options.subset) { + options.subset = subsetCheck; + } + return options.subset === subsetCheck ? undefined : false; + } + return false; + } + }; + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + return h.eachInUnique(a, subsetCompare, b, subsetCompare, true); + } + }, + unionArrayLike: function (a, b, aParent, bParent, prop, compares, options) { + if (Array.isArray(a) && Array.isArray(b)) { + var combined = makeArray(a).concat(makeArray(b)); + h.doubleLoop(combined, function (item, j, cur, i) { + var res = !compareHelpers.equal(cur, item, aParent, bParent, undefined, compares['*'], { 'default': false }); + return res; + }); + options.result[prop] = combined; + return true; + } + }, + count: function (a, b, aParent, bParent, prop, compares, options) { + options.checks = [ + compareHelpers.countComparesType, + compareHelpers.equalBasicTypes, + compareHelpers.equalArrayLike, + compareHelpers.loopObject + ]; + options['default'] = false; + loop(a, b, aParent, bParent, prop, compares, options); + if (typeof options.count === 'number') { + return options.count; + } + return Infinity; + }, + countComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return true; + } else if (compareResult && typeof compareResult === 'object') { + if (typeof compareResult.count === 'number') { + if (!('count' in options) || compareResult.count === options.count) { + options.count = compareResult.count; + } else { + options.count = Infinity; + } + } + return true; + } + } + }, + loopObject: function (a, b, aParent, bParent, prop, compares, options) { + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + each(a, function (aValue, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + loop(aValue, b[prop], a, b, prop, compare, options); + }); + return true; + } + }, + intersection: function (a, b, aParent, bParent, prop, compares, options) { + options.result = {}; + options.performedIntersection = 0; + options.checks = [ + compareHelpers.intersectionComparesType, + addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'), + addToResult(compareHelpers.intersectionArrayLike, 'intersectionArrayLike'), + addResultsToNewObject(compareHelpers.intersectionObject) + ]; + options['default'] = false; + var res = loop(a, b, aParent, bParent, prop, compares, options); + if (res === true) { + return options.result; + } + return false; + }, + intersectionComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + if (compareResult === true) { + options.result[prop] = a; + return true; + } else { + return compareResult; + } + } else if (compareResult && typeof compareResult === 'object') { + if ('intersection' in compareResult) { + if (compareResult.intersection !== undefined) { + options.result[prop] = compareResult.intersection; + } + options.performedIntersection++; + return true; + } + } + } + }, + intersectionObject: function (a, b, aParent, bParent, prop, compares, options) { + var subsetCompare = function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options)) { + return addIntersectedPropertyToResult(a, b, aParent, bParent, prop, compares, options); + } + }; + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + return h.eachInUnique(a, subsetCompare, b, subsetCompare, true); + } + }, + intersectionArrayLike: function (a, b, aParent, bParent, prop, compares, options) { + if (Array.isArray(a) && Array.isArray(b)) { + var intersection = []; + each(makeArray(a), function (cur) { + for (var i = 0; i < b.length; i++) { + if (compareHelpers.equal(cur, b[i], aParent, bParent, undefined, compares['*'], { 'default': false })) { + intersection.push(cur); + break; + } + } + }); + options.result[prop] = intersection; + return true; + } + } + }; +}); \ No newline at end of file diff --git a/dist/amd/src/get.js b/dist/amd/src/get.js new file mode 100644 index 0000000..76818da --- /dev/null +++ b/dist/amd/src/get.js @@ -0,0 +1,43 @@ +/*can-set@1.5.2#src/get*/ +define([ + 'require', + 'exports', + 'module', + './compare', + './helpers', + 'can-util/js/each' +], function (require, exports, module) { + 'use strict'; + var compare = require('./compare'); + var h = require('./helpers'); + var each = require('can-util/js/each'); + var filterData = function (data, clause, props) { + return h.filter.call(data, function (item) { + var isSubset = compare.subset(item, clause, undefined, undefined, undefined, props, {}); + return isSubset; + }); + }; + module.exports = { + subsetData: function (a, b, bData, algebra) { + var aClauseProps = algebra.getClauseProperties(a); + var bClauseProps = algebra.getClauseProperties(b); + var options = {}; + var aData = filterData(bData, aClauseProps.where, algebra.clauses.where); + if (aData.length && (aClauseProps.enabled.order || bClauseProps.enabled.order)) { + options = {}; + var propName = h.firstProp(aClauseProps.order), compareOrder = algebra.clauses.order[propName]; + aData = aData.sort(function (aItem, bItem) { + return compareOrder(a[propName], aItem, bItem); + }); + } + if (aData.length && (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate)) { + options = {}; + compare.subset(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, algebra.clauses.paginate, options); + each(options.getSubsets, function (filter) { + aData = filter(a, b, aData, algebra, options); + }); + } + return aData; + } + }; +}); \ No newline at end of file diff --git a/dist/amd/src/helpers.js b/dist/amd/src/helpers.js new file mode 100644 index 0000000..f9b9980 --- /dev/null +++ b/dist/amd/src/helpers.js @@ -0,0 +1,180 @@ +/*can-set@1.5.2#src/helpers*/ +define([ + 'require', + 'exports', + 'module', + 'can-util/js/assign', + 'can-util/js/each', + 'can-util/js/last' +], function (require, exports, module) { + 'use strict'; + var assign = require('can-util/js/assign'); + var each = require('can-util/js/each'); + var last = require('can-util/js/last'); + var IgnoreType = function () { + }; + var helpers; + module.exports = helpers = { + eachInUnique: function (a, acb, b, bcb, defaultReturn) { + var bCopy = assign({}, b), res; + for (var prop in a) { + res = acb(a[prop], b[prop], a, b, prop); + if (res !== undefined) { + return res; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + res = bcb(undefined, b[prop], a, b, prop); + if (res !== undefined) { + return res; + } + } + return defaultReturn; + }, + doubleLoop: function (arr, callbacks) { + if (typeof callbacks === 'function') { + callbacks = { iterate: callbacks }; + } + var i = 0; + while (i < arr.length) { + if (callbacks.start) { + callbacks.start(arr[i]); + } + var j = i + 1; + while (j < arr.length) { + if (callbacks.iterate(arr[j], j, arr[i], i) === false) { + arr.splice(j, 1); + } else { + j++; + } + } + if (callbacks.end) { + callbacks.end(arr[i]); + } + i++; + } + }, + identityMap: function (arr) { + var map = {}; + each(arr, function (value) { + map[value] = 1; + }); + return map; + }, + arrayUnionIntersectionDifference: function (arr1, arr2) { + var map = {}; + var intersection = []; + var union = []; + var difference = arr1.slice(0); + each(arr1, function (value) { + map[value] = true; + union.push(value); + }); + each(arr2, function (value) { + if (map[value]) { + intersection.push(value); + var index = helpers.indexOf.call(difference, value); + if (index !== -1) { + difference.splice(index, 1); + } + } else { + union.push(value); + } + }); + return { + intersection: intersection, + union: union, + difference: difference + }; + }, + arraySame: function (arr1, arr2) { + if (arr1.length !== arr2.length) { + return false; + } + var map = helpers.identityMap(arr1); + for (var i = 0; i < arr2.length; i++) { + var val = map[arr2[i]]; + if (!val) { + return false; + } else if (val > 1) { + return false; + } else { + map[arr2[i]]++; + } + } + return true; + }, + indexOf: Array.prototype.indexOf || function (item) { + for (var i = 0, thisLen = this.length; i < thisLen; i++) { + if (this[i] === item) { + return i; + } + } + return -1; + }, + map: Array.prototype.map || function (cb) { + var out = []; + for (var i = 0, len = this.length; i < len; i++) { + out.push(cb(this[i], i, this)); + } + return out; + }, + filter: Array.prototype.filter || function (cb) { + var out = []; + for (var i = 0, len = this.length; i < len; i++) { + if (cb(this[i], i, this)) { + out.push(this[i]); + } + } + return out; + }, + ignoreType: new IgnoreType(), + firstProp: function (set) { + for (var prop in set) { + return prop; + } + }, + index: function (compare, items, props) { + if (!items || !items.length) { + return undefined; + } + if (compare(props, items[0]) === -1) { + return 0; + } else if (compare(props, last(items)) === 1) { + return items.length; + } + var low = 0, high = items.length; + while (low < high) { + var mid = low + high >>> 1, item = items[mid], computed = compare(props, item); + if (computed === -1) { + high = mid; + } else { + low = mid + 1; + } + } + return high; + }, + defaultSort: function (sortPropValue, item1, item2) { + var parts = sortPropValue.split(' '); + var sortProp = parts[0]; + var item1Value = item1[sortProp]; + var item2Value = item2[sortProp]; + var temp; + var desc = parts[1] || ''; + desc = desc.toLowerCase() === 'desc'; + if (desc) { + temp = item1Value; + item1Value = item2Value; + item2Value = temp; + } + if (item1Value < item2Value) { + return -1; + } + if (item1Value > item2Value) { + return 1; + } + return 0; + } + }; +}); \ No newline at end of file diff --git a/dist/amd/src/props.js b/dist/amd/src/props.js new file mode 100644 index 0000000..0268c55 --- /dev/null +++ b/dist/amd/src/props.js @@ -0,0 +1,418 @@ +/*can-set@1.5.2#src/props*/ +define([ + 'require', + 'exports', + 'module', + './helpers', + './clause', + 'can-util/js/each' +], function (require, exports, module) { + 'use strict'; + var h = require('./helpers'); + var clause = require('./clause'); + var each = require('can-util/js/each'); + var within = function (value, range) { + return value >= range[0] && value <= range[1]; + }; + var numericProperties = function (setA, setB, property1, property2) { + return { + sAv1: +setA[property1], + sAv2: +setA[property2], + sBv1: +setB[property1], + sBv2: +setB[property2] + }; + }; + var diff = function (setA, setB, property1, property2) { + var numProps = numericProperties(setA, setB, property1, property2); + var sAv1 = numProps.sAv1, sAv2 = numProps.sAv2, sBv1 = numProps.sBv1, sBv2 = numProps.sBv2, count = sAv2 - sAv1 + 1; + var after = { + difference: [ + sBv2 + 1, + sAv2 + ], + intersection: [ + sAv1, + sBv2 + ], + union: [ + sBv1, + sAv2 + ], + count: count, + meta: 'after' + }; + var before = { + difference: [ + sAv1, + sBv1 - 1 + ], + intersection: [ + sBv1, + sAv2 + ], + union: [ + sAv1, + sBv2 + ], + count: count, + meta: 'before' + }; + if (sAv1 === sBv1 && sAv2 === sBv2) { + return { + intersection: [ + sAv1, + sAv2 + ], + union: [ + sAv1, + sAv2 + ], + count: count, + meta: 'equal' + }; + } else if (sAv1 === sBv1 && sBv2 < sAv2) { + return after; + } else if (sAv2 === sBv2 && sBv1 > sAv1) { + return before; + } else if (within(sAv1, [ + sBv1, + sBv2 + ]) && within(sAv2, [ + sBv1, + sBv2 + ])) { + return { + intersection: [ + sAv1, + sAv2 + ], + union: [ + sBv1, + sBv2 + ], + count: count, + meta: 'subset' + }; + } else if (within(sBv1, [ + sAv1, + sAv2 + ]) && within(sBv2, [ + sAv1, + sAv2 + ])) { + return { + intersection: [ + sBv1, + sBv2 + ], + difference: [ + null, + null + ], + union: [ + sAv1, + sAv2 + ], + count: count, + meta: 'superset' + }; + } else if (sAv1 < sBv1 && within(sAv2, [ + sBv1, + sBv2 + ])) { + return before; + } else if (sBv1 < sAv1 && within(sBv2, [ + sAv1, + sAv2 + ])) { + return after; + } else if (sAv2 === sBv1 - 1) { + return { + difference: [ + sAv1, + sAv2 + ], + union: [ + sAv1, + sBv2 + ], + count: count, + meta: 'disjoint-before' + }; + } else if (sBv2 === sAv1 - 1) { + return { + difference: [ + sAv1, + sAv2 + ], + union: [ + sBv1, + sAv2 + ], + count: count, + meta: 'disjoint-after' + }; + } + if (!isNaN(count)) { + return { + count: count, + meta: 'disjoint' + }; + } + }; + var cleanUp = function (value, enumData) { + if (!value) { + return enumData; + } + if (!Array.isArray(value)) { + value = [value]; + } + if (!value.length) { + return enumData; + } + return value; + }; + var stringConvert = { + '0': false, + 'false': false, + 'null': undefined, + 'undefined': undefined + }; + var convertToBoolean = function (value) { + if (typeof value === 'string') { + return value.toLowerCase() in stringConvert ? stringConvert[value.toLowerCase()] : true; + } + return value; + }; + var props = { + 'enum': function (prop, enumData) { + var compares = new clause.Where({}); + compares[prop] = function (vA, vB, A, B) { + vA = cleanUp(vA, enumData); + vB = cleanUp(vB, enumData); + var data = h.arrayUnionIntersectionDifference(vA, vB); + if (!data.difference.length) { + delete data.difference; + } + each(data, function (value, prop) { + if (Array.isArray(value)) { + if (h.arraySame(enumData, value)) { + data[prop] = undefined; + } else if (value.length === 1) { + data[prop] = value[0]; + } + } + }); + return data; + }; + return compares; + }, + paginate: function (propStart, propEnd, translateToStartEnd, reverseTranslate) { + var compares = {}; + var makeResult = function (result, index) { + var res = {}; + each([ + 'intersection', + 'difference', + 'union' + ], function (prop) { + if (result[prop]) { + var set = { + start: result[prop][0], + end: result[prop][1] + }; + res[prop] = reverseTranslate(set)[index === 0 ? propStart : propEnd]; + } + }); + if (result.count) { + res.count = result.count; + } + return res; + }; + compares[propStart] = function (vA, vB, A, B) { + if (vA === undefined) { + return; + } + var res = diff(translateToStartEnd(A), translateToStartEnd(B), 'start', 'end'); + var result = makeResult(res, 0); + result.getSubset = function (a, b, bItems, algebra, options) { + return bItems; + }; + result.getUnion = function (a, b, aItems, bItems, algebra, options) { + return [ + aItems, + bItems + ]; + }; + return result; + }; + compares[propEnd] = function (vA, vB, A, B) { + if (vA === undefined) { + return; + } + var data = diff(translateToStartEnd(A), translateToStartEnd(B), 'start', 'end'); + var res = makeResult(data, 1); + res.getSubset = function (a, b, bItems, algebra, options) { + var tA = translateToStartEnd(a); + var tB = translateToStartEnd(b); + var numProps = numericProperties(tA, tB, 'start', 'end'); + var aStartValue = numProps.sAv1, aEndValue = numProps.sAv2; + var bStartValue = numProps.sBv1; + if (!('end' in tB) || !('end' in tA)) { + return bItems.slice(aStartValue, aEndValue + 1); + } + return bItems.slice(aStartValue - bStartValue, aEndValue - bStartValue + 1); + }; + res.getUnion = function (a, b, aItems, bItems, algebra, options) { + var tA = translateToStartEnd(a); + var tB = translateToStartEnd(b); + if (data.meta.indexOf('after') >= 0) { + if (data.intersection) { + bItems = bItems.slice(0, data.intersection[0] - +tB.start); + } + return [ + bItems, + aItems + ]; + } + if (data.intersection) { + aItems = aItems.slice(0, data.intersection[0] - +tA.start); + } + return [ + aItems, + bItems + ]; + }; + return res; + }; + return new clause.Paginate(compares); + }, + 'boolean': function (propertyName) { + var compares = new clause.Where({}); + compares[propertyName] = function (propA, propB) { + propA = convertToBoolean(propA); + propB = convertToBoolean(propB); + var notA = !propA, notB = !propB; + if (propA === notB && propB === notA) { + return { + difference: !propB, + union: undefined + }; + } else if (propA === undefined) { + return { + difference: !propB, + intersection: propB, + union: undefined + }; + } else if (propA === propB) { + return true; + } + }; + return compares; + }, + 'sort': function (prop, sortFunc) { + if (!sortFunc) { + sortFunc = h.defaultSort; + } + var compares = {}; + compares[prop] = sortFunc; + return new clause.Order(compares); + }, + 'id': function (prop) { + var compares = {}; + compares[prop] = prop; + return new clause.Id(compares); + } + }; + var assignExcept = function (d, s, props) { + for (var prop in s) { + if (!props[prop]) { + d[prop] = s[prop]; + } + } + return d; + }; + var translateToOffsetLimit = function (set, offsetProp, limitProp) { + var newSet = assignExcept({}, set, { + start: 1, + end: 1 + }); + if ('start' in set) { + newSet[offsetProp] = set.start; + } + if ('end' in set) { + newSet[limitProp] = set.end - set.start + 1; + } + return newSet; + }; + var translateToStartEnd = function (set, offsetProp, limitProp) { + var except = {}; + except[offsetProp] = except[limitProp] = 1; + var newSet = assignExcept({}, set, except); + if (offsetProp in set) { + newSet.start = parseInt(set[offsetProp], 10); + } + if (limitProp in set) { + newSet.end = newSet.start + parseInt(set[limitProp]) - 1; + } + return newSet; + }; + props.offsetLimit = function (offsetProp, limitProp) { + offsetProp = offsetProp || 'offset'; + limitProp = limitProp || 'limit'; + return props.paginate(offsetProp, limitProp, function (set) { + return translateToStartEnd(set, offsetProp, limitProp); + }, function (set) { + return translateToOffsetLimit(set, offsetProp, limitProp); + }); + }; + props.rangeInclusive = function (startIndexProperty, endIndexProperty) { + startIndexProperty = startIndexProperty || 'start'; + endIndexProperty = endIndexProperty || 'end'; + return props.paginate(startIndexProperty, endIndexProperty, function (set) { + var except = {}; + except[startIndexProperty] = except[endIndexProperty] = 1; + var newSet = assignExcept({}, set, except); + if (startIndexProperty in set) { + newSet.start = set[startIndexProperty]; + } + if (endIndexProperty in set) { + newSet.end = set[endIndexProperty]; + } + return newSet; + }, function (set) { + var except = { + start: 1, + end: 1 + }; + var newSet = assignExcept({}, set, except); + newSet[startIndexProperty] = set.start; + newSet[endIndexProperty] = set.end; + return newSet; + }); + }; + var nestedLookup = function (obj, propNameArray) { + if (obj === undefined) { + return undefined; + } + if (propNameArray.length === 1) { + return obj[propNameArray[0]]; + } else { + return nestedLookup(obj[propNameArray[0]], propNameArray.slice(1)); + } + }; + props.dotNotation = function (dotProperty) { + var compares = new clause.Where({}); + compares[dotProperty] = function (aVal, bVal, a, b, propertyName) { + if (aVal === undefined) { + aVal = nestedLookup(a, propertyName.split('.')); + } + if (bVal === undefined) { + bVal = nestedLookup(b, propertyName.split('.')); + } + return aVal === bVal; + }; + return compares; + }; + module.exports = props; +}); \ No newline at end of file diff --git a/dist/amd/src/set-core.js b/dist/amd/src/set-core.js new file mode 100644 index 0000000..c90ce27 --- /dev/null +++ b/dist/amd/src/set-core.js @@ -0,0 +1,378 @@ +/*can-set@1.5.2#src/set-core*/ +define([ + 'require', + 'exports', + 'module', + './helpers', + './clause', + './compare', + './get', + 'can-assign', + 'can-util/js/each', + 'can-util/js/make-array', + 'can-util/js/is-empty-object', + 'can-util/js/get' +], function (require, exports, module) { + 'use strict'; + var h = require('./helpers'); + var clause = require('./clause'); + var compare = require('./compare'); + var get = require('./get'); + var assign = require('can-assign'); + var each = require('can-util/js/each'); + var makeArray = require('can-util/js/make-array'); + var isEmptyObject = require('can-util/js/is-empty-object'); + var getProp = require('can-util/js/get'); + function concatUnique(aItems, bItems, algebra) { + var idTree = {}; + var aSet; + if (typeof Set !== 'undefined') { + aSet = new Set(); + } + aItems.forEach(function (item) { + var keyNode = idTree; + if (aSet) { + aSet.add(item); + } + each(algebra.clauses.id, function (prop) { + var propVal = getProp(item, prop); + if (keyNode && typeof propVal !== 'undefined') { + keyNode = keyNode[propVal] = keyNode[propVal] || {}; + } else { + keyNode = undefined; + } + }); + }); + return aItems.concat(bItems.filter(function (item) { + var keyNode = idTree; + if (aSet && aSet.has(item)) { + return false; + } + if (!aSet && aItems.indexOf(item) > -1) { + return false; + } + each(algebra.clauses.id, function (prop) { + keyNode = keyNode && keyNode[getProp(item, prop)]; + }); + return keyNode === idTree || !keyNode; + })); + } + function Translate(clause, options) { + if (typeof options === 'string') { + var path = options; + options = { + fromSet: function (set, setRemainder) { + return set[path] || {}; + }, + toSet: function (set, wheres) { + set[path] = wheres; + return set; + } + }; + } + this.clause = clause; + assign(this, options); + } + var Algebra = function () { + var clauses = this.clauses = { + where: {}, + order: {}, + paginate: {}, + id: {} + }; + this.translators = { + where: new Translate('where', { + fromSet: function (set, setRemainder) { + return setRemainder; + }, + toSet: function (set, wheres) { + return assign(set, wheres); + } + }) + }; + var self = this; + each(arguments, function (arg) { + if (arg) { + if (arg instanceof Translate) { + self.translators[arg.clause] = arg; + } else { + assign(clauses[arg.constructor.type || 'where'], arg); + } + } + }); + }; + Algebra.make = function (compare, count) { + if (compare instanceof Algebra) { + return compare; + } else { + return new Algebra(compare, count); + } + }; + assign(Algebra.prototype, { + getClauseProperties: function (set, options) { + options = options || {}; + var setClone = assign({}, set); + var clauses = this.clauses; + var checkClauses = [ + 'order', + 'paginate', + 'id' + ]; + var clauseProps = { + enabled: { + where: true, + order: false, + paginate: false, + id: false + } + }; + if (options.omitClauses) { + checkClauses = h.arrayUnionIntersectionDifference(checkClauses, options.omitClauses).difference; + } + each(checkClauses, function (clauseName) { + var valuesForClause = {}; + var prop; + for (prop in clauses[clauseName]) { + if (prop in setClone) { + valuesForClause[prop] = setClone[prop]; + if (clauseName !== 'id') { + delete setClone[prop]; + } + } + } + clauseProps[clauseName] = valuesForClause; + clauseProps.enabled[clauseName] = !isEmptyObject(valuesForClause); + }); + clauseProps.where = options.isProperties ? setClone : this.translators.where.fromSet(set, setClone); + return clauseProps; + }, + getDifferentClauseTypes: function (aClauses, bClauses) { + var self = this; + var differentTypes = []; + each(clause.TYPES, function (type) { + if (!self.evaluateOperator(compare.equal, aClauses[type], bClauses[type], { isProperties: true }, { isProperties: true })) { + differentTypes.push(type); + } + }); + return differentTypes; + }, + updateSet: function (set, clause, result, useSet) { + if (result && typeof result === 'object' && useSet !== false) { + if (this.translators[clause]) { + set = this.translators.where.toSet(set, result); + } else { + set = assign(set, result); + } + return true; + } else if (result) { + return useSet === undefined ? undefined : false; + } else { + return false; + } + }, + evaluateOperator: function (operator, a, b, aOptions, bOptions, evaluateOptions) { + aOptions = aOptions || {}; + bOptions = bOptions || {}; + evaluateOptions = assign({ + 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, {}, {}); + } + }, evaluateOptions || {}); + var aClauseProps = this.getClauseProperties(a, aOptions), bClauseProps = this.getClauseProperties(b, bOptions), set = {}, useSet; + var result = evaluateOptions.evaluateWhere(aClauseProps.where, bClauseProps.where, undefined, undefined, undefined, this.clauses.where, {}); + useSet = this.updateSet(set, 'where', result, useSet); + if (result && evaluateOptions.shouldEvaluatePaginate(aClauseProps, bClauseProps)) { + if (evaluateOptions.shouldEvaluateOrder(aClauseProps, bClauseProps)) { + result = evaluateOptions.evaluateOrder(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {}); + useSet = this.updateSet(set, 'order', result, useSet); + } + if (result) { + result = evaluateOptions.evaluatePaginate(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, this.clauses.paginate, {}); + useSet = this.updateSet(set, 'paginate', result, useSet); + } + } else if (result && evaluateOptions.shouldEvaluateOrder(aClauseProps, bClauseProps)) { + result = operator(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {}); + useSet = this.updateSet(set, 'order', result, useSet); + } + return result && useSet ? set : result; + }, + equal: function (a, b) { + return this.evaluateOperator(compare.equal, a, b); + }, + subset: function (a, b) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var compatibleSort = true; + var result; + if (bClauseProps.enabled.paginate && (aClauseProps.enabled.order || bClauseProps.enabled.order)) { + compatibleSort = compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {}); + } + if (!compatibleSort) { + result = false; + } else { + result = this.evaluateOperator(compare.subset, a, b); + } + return result; + }, + properSubset: function (a, b) { + return this.subset(a, b) && !this.equal(a, b); + }, + difference: function (a, b) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var differentClauses = this.getDifferentClauseTypes(aClauseProps, bClauseProps); + var clause, result; + if (differentClauses.length > 2) { + result = false; + } else if (differentClauses.length === 2 && (differentClauses[0] !== 'where' || differentClauses[1] !== 'id')) { + result = false; + } else { + switch (clause = differentClauses[0]) { + case undefined: + case 'order': { + result = false; + break; + } + case 'paginate': + case 'where': { + result = compare.difference(aClauseProps[clause], bClauseProps[clause], undefined, undefined, undefined, this.clauses[clause], {}); + if (typeof result === 'object') { + if (this.translators[clause]) { + result = this.translators[clause].toSet({}, result); + } + assign(result, aClauseProps.order); + if (clause === 'paginate') { + assign(result, aClauseProps.where); + } else if (differentClauses[1] === 'id') { + result = compare.difference(aClauseProps.id, bClauseProps.id, undefined, undefined, undefined, this.clauses.id, {}); + } + } + break; + } + } + } + return result; + }, + union: function (a, b) { + return this.evaluateOperator(compare.union, a, b); + }, + intersection: function (a, b) { + return this.evaluateOperator(compare.intersection, a, b); + }, + count: function (set) { + return this.evaluateOperator(compare.count, set, {}); + }, + has: function (set, props) { + var result = this.evaluateOperator(compare.subset, props, set, { isProperties: true }, undefined, { + shouldEvaluatePaginate: function () { + return false; + } + }); + return result; + }, + index: function (set, items, item) { + var aClauseProps = this.getClauseProperties(set); + var propName = h.firstProp(aClauseProps.order), compare, orderValue; + if (propName) { + compare = this.clauses.order[propName]; + orderValue = set[propName]; + return h.index(function (itemA, itemB) { + return compare(orderValue, itemA, itemB); + }, items, item); + } + propName = h.firstProp(this.clauses.id); + if (propName) { + compare = h.defaultSort; + orderValue = propName; + return h.index(function (itemA, itemB) { + return compare(orderValue, itemA, itemB); + }, items, item); + } + return; + }, + getSubset: function (a, b, bData) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var isSubset = this.subset(assign({}, aClauseProps.where, aClauseProps.paginate), assign({}, bClauseProps.where, bClauseProps.paginate)); + if (isSubset) { + return get.subsetData(a, b, bData, this); + } + }, + getUnion: function (a, b, aItems, bItems) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var algebra = this; + var options; + if (this.subset(a, b)) { + return bItems; + } else if (this.subset(b, a)) { + return aItems; + } + var combined; + if (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate) { + options = {}; + var isUnion = compare.union(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, this.clauses.paginate, options); + if (!isUnion) { + return; + } else { + each(options.getUnions, function (filter) { + var items = filter(a, b, aItems, bItems, algebra, options); + aItems = items[0]; + bItems = items[1]; + }); + combined = concatUnique(aItems, bItems, this); + } + } else { + combined = concatUnique(aItems, bItems, this); + } + if (combined.length && aClauseProps.enabled.order && compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {})) { + options = {}; + var propName = h.firstProp(aClauseProps.order), compareOrder = algebra.clauses.order[propName]; + combined = combined.sort(function (aItem, bItem) { + return compareOrder(a[propName], aItem, bItem); + }); + } + return combined; + }, + id: function (props) { + var keys = Object.keys(this.clauses.id); + if (keys.length === 1) { + return props[keys[0]]; + } else { + var id = {}; + keys.forEach(function (key) { + id[key] = props[key]; + }); + return JSON.stringify(id); + } + } + }); + var callOnAlgebra = function (methodName, algebraArgNumber) { + return function () { + var args = makeArray(arguments).slice(0, algebraArgNumber); + var algebra = Algebra.make(arguments[algebraArgNumber]); + return algebra[methodName].apply(algebra, args); + }; + }; + module.exports = { + Algebra: Algebra, + Translate: Translate, + difference: callOnAlgebra('difference', 2), + equal: callOnAlgebra('equal', 2), + subset: callOnAlgebra('subset', 2), + properSubset: callOnAlgebra('properSubset', 2), + union: callOnAlgebra('union', 2), + intersection: callOnAlgebra('intersection', 2), + count: callOnAlgebra('count', 1), + has: callOnAlgebra('has', 2), + index: callOnAlgebra('index', 3), + getSubset: callOnAlgebra('getSubset', 3), + getUnion: callOnAlgebra('getUnion', 4) + }; +}); \ No newline at end of file diff --git a/dist/amd/src/set.js b/dist/amd/src/set.js new file mode 100644 index 0000000..98c1a96 --- /dev/null +++ b/dist/amd/src/set.js @@ -0,0 +1,22 @@ +/*can-set@1.5.2#src/set*/ +define([ + 'require', + 'exports', + 'module', + './set-core', + 'can-namespace', + './props', + './clause', + './helpers' +], function (require, exports, module) { + 'use strict'; + var set = require('./set-core'); + var ns = require('can-namespace'); + var props = require('./props'); + var clause = require('./clause'); + set.comparators = props; + set.props = props; + set.helpers = require('./helpers'); + set.clause = clause; + module.exports = ns.set = set; +}); \ No newline at end of file diff --git a/dist/global/can-set.js b/dist/global/can-set.js new file mode 100644 index 0000000..c6a888e --- /dev/null +++ b/dist/global/can-set.js @@ -0,0 +1,2016 @@ +/*[process-shim]*/ +(function(global, env) { + // jshint ignore:line + if (typeof process === "undefined") { + global.process = { + argv: [], + cwd: function() { + return ""; + }, + browser: true, + env: { + NODE_ENV: env || "development" + }, + version: "", + platform: + global.navigator && + global.navigator.userAgent && + /Windows/.test(global.navigator.userAgent) + ? "win" + : "" + }; + } +})( + typeof self == "object" && self.Object == Object + ? self + : typeof process === "object" && + Object.prototype.toString.call(process) === "[object process]" + ? global + : window, + "development" +); + +/*[global-shim-start]*/ +(function(exports, global, doEval) { + // jshint ignore:line + var origDefine = global.define; + + var get = function(name) { + var parts = name.split("."), + cur = global, + i; + for (i = 0; i < parts.length; i++) { + if (!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var set = function(name, val) { + var parts = name.split("."), + cur = global, + i, + part, + next; + for (i = 0; i < parts.length - 1; i++) { + part = parts[i]; + next = cur[part]; + if (!next) { + next = cur[part] = {}; + } + cur = next; + } + part = parts[parts.length - 1]; + cur[part] = val; + }; + var useDefault = function(mod) { + if (!mod || !mod.__esModule) return false; + var esProps = { __esModule: true, default: true }; + for (var p in mod) { + if (!esProps[p]) return false; + } + return true; + }; + + var hasCjsDependencies = function(deps) { + return ( + deps[0] === "require" && deps[1] === "exports" && deps[2] === "module" + ); + }; + + var modules = + (global.define && global.define.modules) || + (global._define && global._define.modules) || + {}; + var ourDefine = (global.define = function(moduleName, deps, callback) { + var module; + if (typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for (i = 0; i < deps.length; i++) { + args.push( + exports[deps[i]] + ? get(exports[deps[i]]) + : modules[deps[i]] || get(deps[i]) + ); + } + // CJS has no dependencies but 3 callback arguments + if (hasCjsDependencies(deps) || (!deps.length && callback.length)) { + module = { exports: {} }; + args[0] = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args[1] = module.exports; + args[2] = module; + } else if (!args[0] && deps[0] === "exports") { + // Babel uses the exports and module object. + module = { exports: {} }; + args[0] = module.exports; + if (deps[1] === "module") { + args[1] = module; + } + } else if (!args[0] && deps[0] === "module") { + args[0] = { id: moduleName }; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + result = module && module.exports ? module.exports : result; + modules[moduleName] = result; + + // Set global exports + var globalExport = exports[moduleName]; + if (globalExport && !get(globalExport)) { + if (useDefault(result)) { + result = result["default"]; + } + set(globalExport, result); + } + }); + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + ourDefine("@loader", [], function() { + // shim for @@global-helpers + var noop = function() {}; + return { + get: function() { + return { prepareGlobal: noop, retrieveGlobal: noop }; + }, + global: global, + __exec: function(__load) { + doEval(__load.source, global); + } + }; + }); +})( + {}, + typeof self == "object" && self.Object == Object + ? self + : typeof process === "object" && + Object.prototype.toString.call(process) === "[object process]" + ? global + : window, + function(__$source__, __$global__) { + // jshint ignore:line + eval("(function() { " + __$source__ + " \n }).call(__$global__);"); + } +); + +/*can-namespace@1.0.0#can-namespace*/ +define('can-namespace', function (require, exports, module) { + module.exports = {}; +}); +/*can-assign@1.2.0#can-assign*/ +define('can-assign', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + var namespace = require('can-namespace'); + module.exports = namespace.assign = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; +}); +/*can-util@3.12.0#js/assign/assign*/ +define('set-can-util/js/assign/assign', [ + 'require', + 'exports', + 'module', + 'can-namespace', + 'can-assign' +], function (require, exports, module) { + 'use strict'; + var namespace = require('can-namespace'); + module.exports = namespace.assign = require('can-assign'); +}); +/*can-util@3.12.0#js/is-array-like/is-array-like*/ +define('set-can-util/js/is-array-like/is-array-like', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + 'use strict'; + var namespace = require('can-namespace'); + function isArrayLike(obj) { + var type = typeof obj; + if (type === 'string') { + return true; + } else if (type === 'number') { + return false; + } + var length = obj && type !== 'boolean' && typeof obj !== 'number' && 'length' in obj && obj.length; + return typeof obj !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + } + module.exports = namespace.isArrayLike = isArrayLike; +}); +/*can-symbol@1.6.1#can-symbol*/ +define('can-symbol', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + (function (global, require, exports, module) { + var namespace = require('can-namespace'); + var CanSymbol; + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + CanSymbol = Symbol; + } else { + var symbolNum = 0; + CanSymbol = function CanSymbolPolyfill(description) { + var symbolValue = '@@symbol' + symbolNum++ + description; + var symbol = {}; + Object.defineProperties(symbol, { + toString: { + value: function () { + return symbolValue; + } + } + }); + return symbol; + }; + var descriptionToSymbol = {}; + var symbolToDescription = {}; + CanSymbol.for = function (description) { + var symbol = descriptionToSymbol[description]; + if (!symbol) { + symbol = descriptionToSymbol[description] = CanSymbol(description); + symbolToDescription[symbol] = description; + } + return symbol; + }; + CanSymbol.keyFor = function (symbol) { + return symbolToDescription[symbol]; + }; + [ + 'hasInstance', + 'isConcatSpreadable', + 'iterator', + 'match', + 'prototype', + 'replace', + 'search', + 'species', + 'split', + 'toPrimitive', + 'toStringTag', + 'unscopables' + ].forEach(function (name) { + CanSymbol[name] = CanSymbol('Symbol.' + name); + }); + } + [ + 'isMapLike', + 'isListLike', + 'isValueLike', + 'isFunctionLike', + 'getOwnKeys', + 'getOwnKeyDescriptor', + 'proto', + 'getOwnEnumerableKeys', + 'hasOwnKey', + 'hasKey', + 'size', + 'getName', + 'getIdentity', + 'assignDeep', + 'updateDeep', + 'getValue', + 'setValue', + 'getKeyValue', + 'setKeyValue', + 'updateValues', + 'addValue', + 'removeValues', + 'apply', + 'new', + 'onValue', + 'offValue', + 'onKeyValue', + 'offKeyValue', + 'getKeyDependencies', + 'getValueDependencies', + 'keyHasDependencies', + 'valueHasDependencies', + 'onKeys', + 'onKeysAdded', + 'onKeysRemoved', + 'onPatches' + ].forEach(function (name) { + CanSymbol.for('can.' + name); + }); + module.exports = namespace.Symbol = CanSymbol; + }(function () { + return this; + }(), require, exports, module)); +}); +/*can-util@3.12.0#js/is-iterable/is-iterable*/ +define('set-can-util/js/is-iterable/is-iterable', [ + 'require', + 'exports', + 'module', + 'can-symbol' +], function (require, exports, module) { + 'use strict'; + var canSymbol = require('can-symbol'); + module.exports = function (obj) { + return obj && !!obj[canSymbol.iterator || canSymbol.for('iterator')]; + }; +}); +/*can-util@3.12.0#js/each/each*/ +define('set-can-util/js/each/each', [ + 'require', + 'exports', + 'module', + 'set-can-util/js/is-array-like/is-array-like', + 'set-can-util/js/is-iterable/is-iterable', + 'can-symbol', + 'can-namespace' +], function (require, exports, module) { + 'use strict'; + var isArrayLike = require('set-can-util/js/is-array-like/is-array-like'); + var has = Object.prototype.hasOwnProperty; + var isIterable = require('set-can-util/js/is-iterable/is-iterable'); + var canSymbol = require('can-symbol'); + var namespace = require('can-namespace'); + function each(elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else if (isIterable(elements)) { + var iter = elements[canSymbol.iterator || canSymbol.for('iterator')](); + var res, value; + while (!(res = iter.next()).done) { + value = res.value; + callback.call(context || elements, Array.isArray(value) ? value[1] : value, value[0]); + } + } else if (typeof elements === 'object') { + for (key in elements) { + if (has.call(elements, key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + return elements; + } + module.exports = namespace.each = each; +}); +/*can-util@3.12.0#js/last/last*/ +define('set-can-util/js/last/last', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + 'use strict'; + var namespace = require('can-namespace'); + module.exports = namespace.last = function (arr) { + return arr && arr[arr.length - 1]; + }; +}); +/*can-set@1.5.2#src/helpers*/ +define('can-set/src/helpers', [ + 'require', + 'exports', + 'module', + 'set-can-util/js/assign/assign', + 'set-can-util/js/each/each', + 'set-can-util/js/last/last' +], function (require, exports, module) { + 'use strict'; + var assign = require('set-can-util/js/assign/assign'); + var each = require('set-can-util/js/each/each'); + var last = require('set-can-util/js/last/last'); + var IgnoreType = function () { + }; + var helpers; + module.exports = helpers = { + eachInUnique: function (a, acb, b, bcb, defaultReturn) { + var bCopy = assign({}, b), res; + for (var prop in a) { + res = acb(a[prop], b[prop], a, b, prop); + if (res !== undefined) { + return res; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + res = bcb(undefined, b[prop], a, b, prop); + if (res !== undefined) { + return res; + } + } + return defaultReturn; + }, + doubleLoop: function (arr, callbacks) { + if (typeof callbacks === 'function') { + callbacks = { iterate: callbacks }; + } + var i = 0; + while (i < arr.length) { + if (callbacks.start) { + callbacks.start(arr[i]); + } + var j = i + 1; + while (j < arr.length) { + if (callbacks.iterate(arr[j], j, arr[i], i) === false) { + arr.splice(j, 1); + } else { + j++; + } + } + if (callbacks.end) { + callbacks.end(arr[i]); + } + i++; + } + }, + identityMap: function (arr) { + var map = {}; + each(arr, function (value) { + map[value] = 1; + }); + return map; + }, + arrayUnionIntersectionDifference: function (arr1, arr2) { + var map = {}; + var intersection = []; + var union = []; + var difference = arr1.slice(0); + each(arr1, function (value) { + map[value] = true; + union.push(value); + }); + each(arr2, function (value) { + if (map[value]) { + intersection.push(value); + var index = helpers.indexOf.call(difference, value); + if (index !== -1) { + difference.splice(index, 1); + } + } else { + union.push(value); + } + }); + return { + intersection: intersection, + union: union, + difference: difference + }; + }, + arraySame: function (arr1, arr2) { + if (arr1.length !== arr2.length) { + return false; + } + var map = helpers.identityMap(arr1); + for (var i = 0; i < arr2.length; i++) { + var val = map[arr2[i]]; + if (!val) { + return false; + } else if (val > 1) { + return false; + } else { + map[arr2[i]]++; + } + } + return true; + }, + indexOf: Array.prototype.indexOf || function (item) { + for (var i = 0, thisLen = this.length; i < thisLen; i++) { + if (this[i] === item) { + return i; + } + } + return -1; + }, + map: Array.prototype.map || function (cb) { + var out = []; + for (var i = 0, len = this.length; i < len; i++) { + out.push(cb(this[i], i, this)); + } + return out; + }, + filter: Array.prototype.filter || function (cb) { + var out = []; + for (var i = 0, len = this.length; i < len; i++) { + if (cb(this[i], i, this)) { + out.push(this[i]); + } + } + return out; + }, + ignoreType: new IgnoreType(), + firstProp: function (set) { + for (var prop in set) { + return prop; + } + }, + index: function (compare, items, props) { + if (!items || !items.length) { + return undefined; + } + if (compare(props, items[0]) === -1) { + return 0; + } else if (compare(props, last(items)) === 1) { + return items.length; + } + var low = 0, high = items.length; + while (low < high) { + var mid = low + high >>> 1, item = items[mid], computed = compare(props, item); + if (computed === -1) { + high = mid; + } else { + low = mid + 1; + } + } + return high; + }, + defaultSort: function (sortPropValue, item1, item2) { + var parts = sortPropValue.split(' '); + var sortProp = parts[0]; + var item1Value = item1[sortProp]; + var item2Value = item2[sortProp]; + var temp; + var desc = parts[1] || ''; + desc = desc.toLowerCase() === 'desc'; + if (desc) { + temp = item1Value; + item1Value = item2Value; + item2Value = temp; + } + if (item1Value < item2Value) { + return -1; + } + if (item1Value > item2Value) { + return 1; + } + return 0; + } + }; +}); +/*can-set@1.5.2#src/clause*/ +define('can-set/src/clause', [ + 'require', + 'exports', + 'module', + 'set-can-util/js/assign/assign', + 'set-can-util/js/each/each' +], function (require, exports, module) { + 'use strict'; + var assign = require('set-can-util/js/assign/assign'); + var each = require('set-can-util/js/each/each'); + var clause = {}; + module.exports = clause; + clause.TYPES = [ + 'where', + 'order', + 'paginate', + 'id' + ]; + each(clause.TYPES, function (type) { + var className = type.charAt(0).toUpperCase() + type.substr(1); + clause[className] = function (compare) { + assign(this, compare); + }; + clause[className].type = type; + }); +}); +/*can-util@3.12.0#js/make-array/make-array*/ +define('set-can-util/js/make-array/make-array', [ + 'require', + 'exports', + 'module', + 'set-can-util/js/each/each', + 'set-can-util/js/is-array-like/is-array-like', + 'can-namespace' +], function (require, exports, module) { + 'use strict'; + var each = require('set-can-util/js/each/each'); + var isArrayLike = require('set-can-util/js/is-array-like/is-array-like'); + var namespace = require('can-namespace'); + function makeArray(element) { + var ret = []; + if (isArrayLike(element)) { + each(element, function (a, i) { + ret[i] = a; + }); + } else if (element === 0 || element) { + ret.push(element); + } + return ret; + } + module.exports = namespace.makeArray = makeArray; +}); +/*can-set@1.5.2#src/compare*/ +define('can-set/src/compare', [ + 'require', + 'exports', + 'module', + 'can-set/src/helpers', + 'set-can-util/js/assign/assign', + 'set-can-util/js/each/each', + 'set-can-util/js/make-array/make-array' +], function (require, exports, module) { + 'use strict'; + var h = require('can-set/src/helpers'); + var assign = require('set-can-util/js/assign/assign'); + var each = require('set-can-util/js/each/each'); + var makeArray = require('set-can-util/js/make-array/make-array'); + var compareHelpers; + var loop = function (a, b, aParent, bParent, prop, compares, options) { + var checks = options.checks; + for (var i = 0; i < checks.length; i++) { + var res = checks[i](a, b, aParent, bParent, prop, compares || {}, options); + if (res !== undefined) { + return res; + } + } + return options['default']; + }; + var addIntersectedPropertyToResult = function (a, b, aParent, bParent, prop, compares, options) { + var subsetCheck; + if (!(prop in aParent)) { + subsetCheck = 'subsetB'; + } else if (prop in bParent) { + return false; + } + if (!(prop in bParent)) { + subsetCheck = 'subsetA'; + } + if (subsetCheck === 'subsetB') { + options.result[prop] = b; + } else { + options.result[prop] = a; + } + return undefined; + }; + var addToResult = function (fn, name) { + return function (a, b, aParent, bParent, prop, compares, options) { + var res = fn.apply(this, arguments); + if (res === true) { + if (prop !== undefined && !(prop in options.result)) { + options.result[prop] = a; + } + return true; + } else { + return res; + } + }; + }; + var addResultsToNewObject = function (fn, name) { + return function (a, b, aParent, bParent, prop, compares, options) { + var existingResult = options.result; + options.result = {}; + var res = fn.apply(this, arguments); + if (res) { + if (prop !== undefined) { + existingResult[prop] = options.result; + } else { + assign(existingResult, options.result); + } + } + options.result = existingResult; + return res; + }; + }; + module.exports = compareHelpers = { + equal: function (a, b, aParent, bParent, prop, compares, options) { + options.checks = [ + compareHelpers.equalComparesType, + compareHelpers.equalBasicTypes, + compareHelpers.equalArrayLike, + compareHelpers.equalObject + ]; + options['default'] = false; + return loop(a, b, aParent, bParent, prop, compares, options); + }, + equalComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return compareResult; + } else if (compareResult && typeof compareResult === 'object') { + if ('intersection' in compareResult && !('difference' in compareResult)) { + var reverseResult = compares(b, a, bParent, aParent, prop, options); + return 'intersection' in reverseResult && !('difference' in reverseResult); + } + return false; + } + return compareResult; + } + }, + equalBasicTypes: function (a, b, aParent, bParent, prop, compares, options) { + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); + } + if (options.deep === -1) { + return typeof a === 'object' || a === b; + } + if (typeof a !== typeof b || Array.isArray(a) !== Array.isArray(b)) { + return false; + } + if (a === b) { + return true; + } + }, + equalArrayLike: function (a, b, aParent, bParent, prop, compares, options) { + if (Array.isArray(a) && Array.isArray(b)) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + var compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!loop(a[i], b[i], a, b, i, compare, options)) { + return false; + } + } + return true; + } + }, + equalObject: function (a, b, aParent, bParent, parentProp, compares, options) { + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + var bCopy = assign({}, b); + if (options.deep === false) { + options.deep = -1; + } + for (var prop in a) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a[prop], b[prop], a, b, prop, compare, options)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !loop(undefined, b[prop], a, b, prop, compares[prop], options)) { + return false; + } + } + return true; + } + }, + subset: function (a, b, aParent, bParent, prop, compares, options) { + options.checks = [ + compareHelpers.subsetComparesType, + compareHelpers.equalBasicTypes, + compareHelpers.equalArrayLike, + compareHelpers.subsetObject + ]; + options.getSubsets = []; + options['default'] = false; + return loop(a, b, aParent, bParent, prop, compares, options); + }, + subsetObject: function (a, b, aParent, bParent, parentProp, compares, options) { + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + return h.eachInUnique(a, function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options) && prop in bParent) { + return false; + } + }, b, function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options)) { + return false; + } + }, true); + } + }, + subsetComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return compareResult; + } else if (compareResult && typeof compareResult === 'object') { + if (compareResult.getSubset) { + if (h.indexOf.call(options.getSubsets, compareResult.getSubset) === -1) { + options.getSubsets.push(compareResult.getSubset); + } + } + if (compareResult.intersection === h.ignoreType || compareResult.difference === h.ignoreType) { + return true; + } + if ('intersection' in compareResult && !('difference' in compareResult)) { + var reverseResult = compares(b, a, bParent, aParent, prop, options); + return 'intersection' in reverseResult; + } + return false; + } + return compareResult; + } + }, + properSupersetObject: function (a, b, aParent, bParent, parentProp, compares, options) { + var bType = typeof b; + var hasAdditionalProp = false; + if (bType === 'object' || bType === 'function') { + var aCopy = assign({}, a); + if (options.deep === false) { + options.deep = -1; + } + for (var prop in b) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + var compareResult = loop(a[prop], b[prop], a, b, prop, compare, options); + if (compareResult === h.ignoreType) { + } else if (!(prop in a) || options.performedDifference) { + hasAdditionalProp = true; + } else if (!compareResult) { + return false; + } + delete aCopy[prop]; + } + for (prop in aCopy) { + if (compares[prop] === undefined || !loop(a[prop], undefined, a, b, prop, compares[prop], options)) { + return false; + } + } + return hasAdditionalProp; + } + }, + properSubsetComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return compareResult; + } else if (compareResult && typeof compareResult === 'object') { + if ('intersection' in compareResult && !('difference' in compareResult)) { + var reverseResult = compares(b, a, bParent, aParent, prop, options); + return 'intersection' in reverseResult && 'difference' in reverseResult; + } + return false; + } + return compareResult; + } + }, + difference: function (a, b, aParent, bParent, prop, compares, options) { + options.result = {}; + options.performedDifference = 0; + options.checks = [ + compareHelpers.differenceComparesType, + addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'), + addToResult(compareHelpers.equalArrayLike, 'equalArrayLike'), + addToResult(compareHelpers.properSupersetObject, 'properSubsetObject') + ]; + options['default'] = true; + var res = loop(a, b, aParent, bParent, prop, compares, options); + if (res === true && options.performedDifference) { + return options.result; + } + return res; + }, + differenceComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + if (compareResult === true) { + options.result[prop] = a; + return true; + } else { + return compareResult; + } + } else if (compareResult && typeof compareResult === 'object') { + if ('difference' in compareResult) { + if (compareResult.difference === h.ignoreType) { + return h.ignoreType; + } else if (compareResult.difference != null) { + options.result[prop] = compareResult.difference; + options.performedDifference++; + return true; + } else { + return true; + } + } else { + if (compareHelpers.equalComparesType.apply(this, arguments)) { + options.performedDifference++; + options.result[prop] = compareResult.union; + } else { + return false; + } + } + } + } + }, + union: function (a, b, aParent, bParent, prop, compares, options) { + options.result = {}; + options.performedUnion = 0; + options.checks = [ + compareHelpers.unionComparesType, + addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'), + addToResult(compareHelpers.unionArrayLike, 'unionArrayLike'), + addResultsToNewObject(compareHelpers.unionObject, 'unionObject') + ]; + options.getUnions = []; + options['default'] = false; + var res = loop(a, b, aParent, bParent, prop, compares, options); + if (res === true) { + return options.result; + } + return false; + }, + unionComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + if (compareResult === true) { + options.result[prop] = a; + return true; + } else { + return compareResult; + } + } else if (compareResult && typeof compareResult === 'object') { + if (compareResult.getUnion) { + if (h.indexOf.call(options.getUnions, compareResult.getUnion) === -1) { + options.getUnions.push(compareResult.getUnion); + } + } + if ('union' in compareResult) { + if (compareResult.union === h.ignoreType) { + return compareResult.union; + } + if (compareResult.union !== undefined) { + options.result[prop] = compareResult.union; + } + options.performedUnion++; + return true; + } + } + } + }, + unionObject: function (a, b, aParent, bParent, prop, compares, options) { + var subsetCompare = function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options)) { + var subsetCheck; + if (!(prop in aParent)) { + subsetCheck = 'subsetB'; + } + if (!(prop in bParent)) { + subsetCheck = 'subsetA'; + } + if (subsetCheck) { + if (!options.subset) { + options.subset = subsetCheck; + } + return options.subset === subsetCheck ? undefined : false; + } + return false; + } + }; + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + return h.eachInUnique(a, subsetCompare, b, subsetCompare, true); + } + }, + unionArrayLike: function (a, b, aParent, bParent, prop, compares, options) { + if (Array.isArray(a) && Array.isArray(b)) { + var combined = makeArray(a).concat(makeArray(b)); + h.doubleLoop(combined, function (item, j, cur, i) { + var res = !compareHelpers.equal(cur, item, aParent, bParent, undefined, compares['*'], { 'default': false }); + return res; + }); + options.result[prop] = combined; + return true; + } + }, + count: function (a, b, aParent, bParent, prop, compares, options) { + options.checks = [ + compareHelpers.countComparesType, + compareHelpers.equalBasicTypes, + compareHelpers.equalArrayLike, + compareHelpers.loopObject + ]; + options['default'] = false; + loop(a, b, aParent, bParent, prop, compares, options); + if (typeof options.count === 'number') { + return options.count; + } + return Infinity; + }, + countComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + return true; + } else if (compareResult && typeof compareResult === 'object') { + if (typeof compareResult.count === 'number') { + if (!('count' in options) || compareResult.count === options.count) { + options.count = compareResult.count; + } else { + options.count = Infinity; + } + } + return true; + } + } + }, + loopObject: function (a, b, aParent, bParent, prop, compares, options) { + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + each(a, function (aValue, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + loop(aValue, b[prop], a, b, prop, compare, options); + }); + return true; + } + }, + intersection: function (a, b, aParent, bParent, prop, compares, options) { + options.result = {}; + options.performedIntersection = 0; + options.checks = [ + compareHelpers.intersectionComparesType, + addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'), + addToResult(compareHelpers.intersectionArrayLike, 'intersectionArrayLike'), + addResultsToNewObject(compareHelpers.intersectionObject) + ]; + options['default'] = false; + var res = loop(a, b, aParent, bParent, prop, compares, options); + if (res === true) { + return options.result; + } + return false; + }, + intersectionComparesType: function (a, b, aParent, bParent, prop, compares, options) { + if (typeof compares === 'function') { + var compareResult = compares(a, b, aParent, bParent, prop, options); + if (typeof compareResult === 'boolean') { + if (compareResult === true) { + options.result[prop] = a; + return true; + } else { + return compareResult; + } + } else if (compareResult && typeof compareResult === 'object') { + if ('intersection' in compareResult) { + if (compareResult.intersection !== undefined) { + options.result[prop] = compareResult.intersection; + } + options.performedIntersection++; + return true; + } + } + } + }, + intersectionObject: function (a, b, aParent, bParent, prop, compares, options) { + var subsetCompare = function (a, b, aParent, bParent, prop) { + var compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!loop(a, b, aParent, bParent, prop, compare, options)) { + return addIntersectedPropertyToResult(a, b, aParent, bParent, prop, compares, options); + } + }; + var aType = typeof a; + if (aType === 'object' || aType === 'function') { + return h.eachInUnique(a, subsetCompare, b, subsetCompare, true); + } + }, + intersectionArrayLike: function (a, b, aParent, bParent, prop, compares, options) { + if (Array.isArray(a) && Array.isArray(b)) { + var intersection = []; + each(makeArray(a), function (cur) { + for (var i = 0; i < b.length; i++) { + if (compareHelpers.equal(cur, b[i], aParent, bParent, undefined, compares['*'], { 'default': false })) { + intersection.push(cur); + break; + } + } + }); + options.result[prop] = intersection; + return true; + } + } + }; +}); +/*can-set@1.5.2#src/get*/ +define('can-set/src/get', [ + 'require', + 'exports', + 'module', + 'can-set/src/compare', + 'can-set/src/helpers', + 'set-can-util/js/each/each' +], function (require, exports, module) { + 'use strict'; + var compare = require('can-set/src/compare'); + var h = require('can-set/src/helpers'); + var each = require('set-can-util/js/each/each'); + var filterData = function (data, clause, props) { + return h.filter.call(data, function (item) { + var isSubset = compare.subset(item, clause, undefined, undefined, undefined, props, {}); + return isSubset; + }); + }; + module.exports = { + subsetData: function (a, b, bData, algebra) { + var aClauseProps = algebra.getClauseProperties(a); + var bClauseProps = algebra.getClauseProperties(b); + var options = {}; + var aData = filterData(bData, aClauseProps.where, algebra.clauses.where); + if (aData.length && (aClauseProps.enabled.order || bClauseProps.enabled.order)) { + options = {}; + var propName = h.firstProp(aClauseProps.order), compareOrder = algebra.clauses.order[propName]; + aData = aData.sort(function (aItem, bItem) { + return compareOrder(a[propName], aItem, bItem); + }); + } + if (aData.length && (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate)) { + options = {}; + compare.subset(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, algebra.clauses.paginate, options); + each(options.getSubsets, function (filter) { + aData = filter(a, b, aData, algebra, options); + }); + } + return aData; + } + }; +}); +/*can-util@3.12.0#js/is-empty-object/is-empty-object*/ +define('set-can-util/js/is-empty-object/is-empty-object', [ + 'require', + 'exports', + 'module', + 'can-namespace' +], function (require, exports, module) { + 'use strict'; + var namespace = require('can-namespace'); + module.exports = namespace.isEmptyObject = function (obj) { + for (var prop in obj) { + return false; + } + return true; + }; +}); +/*can-util@3.12.0#js/is-container/is-container*/ +define('set-can-util/js/is-container/is-container', function (require, exports, module) { + 'use strict'; + module.exports = function (current) { + return /^f|^o/.test(typeof current); + }; +}); +/*can-util@3.12.0#js/get/get*/ +define('set-can-util/js/get/get', [ + 'require', + 'exports', + 'module', + 'set-can-util/js/is-container/is-container' +], function (require, exports, module) { + 'use strict'; + var isContainer = require('set-can-util/js/is-container/is-container'); + function get(obj, name) { + var parts = typeof name !== 'undefined' ? (name + '').replace(/\[/g, '.').replace(/]/g, '').split('.') : [], length = parts.length, current, i, container; + if (!length) { + return obj; + } + current = obj; + for (i = 0; i < length && isContainer(current) && current !== null; i++) { + container = current; + current = container[parts[i]]; + } + return current; + } + module.exports = get; +}); +/*can-set@1.5.2#src/set-core*/ +define('can-set/src/set-core', [ + 'require', + 'exports', + 'module', + 'can-set/src/helpers', + 'can-set/src/clause', + 'can-set/src/compare', + 'can-set/src/get', + 'can-assign', + 'set-can-util/js/each/each', + 'set-can-util/js/make-array/make-array', + 'set-can-util/js/is-empty-object/is-empty-object', + 'set-can-util/js/get/get' +], function (require, exports, module) { + 'use strict'; + var h = require('can-set/src/helpers'); + var clause = require('can-set/src/clause'); + var compare = require('can-set/src/compare'); + var get = require('can-set/src/get'); + var assign = require('can-assign'); + var each = require('set-can-util/js/each/each'); + var makeArray = require('set-can-util/js/make-array/make-array'); + var isEmptyObject = require('set-can-util/js/is-empty-object/is-empty-object'); + var getProp = require('set-can-util/js/get/get'); + function concatUnique(aItems, bItems, algebra) { + var idTree = {}; + var aSet; + if (typeof Set !== 'undefined') { + aSet = new Set(); + } + aItems.forEach(function (item) { + var keyNode = idTree; + if (aSet) { + aSet.add(item); + } + each(algebra.clauses.id, function (prop) { + var propVal = getProp(item, prop); + if (keyNode && typeof propVal !== 'undefined') { + keyNode = keyNode[propVal] = keyNode[propVal] || {}; + } else { + keyNode = undefined; + } + }); + }); + return aItems.concat(bItems.filter(function (item) { + var keyNode = idTree; + if (aSet && aSet.has(item)) { + return false; + } + if (!aSet && aItems.indexOf(item) > -1) { + return false; + } + each(algebra.clauses.id, function (prop) { + keyNode = keyNode && keyNode[getProp(item, prop)]; + }); + return keyNode === idTree || !keyNode; + })); + } + function Translate(clause, options) { + if (typeof options === 'string') { + var path = options; + options = { + fromSet: function (set, setRemainder) { + return set[path] || {}; + }, + toSet: function (set, wheres) { + set[path] = wheres; + return set; + } + }; + } + this.clause = clause; + assign(this, options); + } + var Algebra = function () { + var clauses = this.clauses = { + where: {}, + order: {}, + paginate: {}, + id: {} + }; + this.translators = { + where: new Translate('where', { + fromSet: function (set, setRemainder) { + return setRemainder; + }, + toSet: function (set, wheres) { + return assign(set, wheres); + } + }) + }; + var self = this; + each(arguments, function (arg) { + if (arg) { + if (arg instanceof Translate) { + self.translators[arg.clause] = arg; + } else { + assign(clauses[arg.constructor.type || 'where'], arg); + } + } + }); + }; + Algebra.make = function (compare, count) { + if (compare instanceof Algebra) { + return compare; + } else { + return new Algebra(compare, count); + } + }; + assign(Algebra.prototype, { + getClauseProperties: function (set, options) { + options = options || {}; + var setClone = assign({}, set); + var clauses = this.clauses; + var checkClauses = [ + 'order', + 'paginate', + 'id' + ]; + var clauseProps = { + enabled: { + where: true, + order: false, + paginate: false, + id: false + } + }; + if (options.omitClauses) { + checkClauses = h.arrayUnionIntersectionDifference(checkClauses, options.omitClauses).difference; + } + each(checkClauses, function (clauseName) { + var valuesForClause = {}; + var prop; + for (prop in clauses[clauseName]) { + if (prop in setClone) { + valuesForClause[prop] = setClone[prop]; + if (clauseName !== 'id') { + delete setClone[prop]; + } + } + } + clauseProps[clauseName] = valuesForClause; + clauseProps.enabled[clauseName] = !isEmptyObject(valuesForClause); + }); + clauseProps.where = options.isProperties ? setClone : this.translators.where.fromSet(set, setClone); + return clauseProps; + }, + getDifferentClauseTypes: function (aClauses, bClauses) { + var self = this; + var differentTypes = []; + each(clause.TYPES, function (type) { + if (!self.evaluateOperator(compare.equal, aClauses[type], bClauses[type], { isProperties: true }, { isProperties: true })) { + differentTypes.push(type); + } + }); + return differentTypes; + }, + updateSet: function (set, clause, result, useSet) { + if (result && typeof result === 'object' && useSet !== false) { + if (this.translators[clause]) { + set = this.translators.where.toSet(set, result); + } else { + set = assign(set, result); + } + return true; + } else if (result) { + return useSet === undefined ? undefined : false; + } else { + return false; + } + }, + evaluateOperator: function (operator, a, b, aOptions, bOptions, evaluateOptions) { + aOptions = aOptions || {}; + bOptions = bOptions || {}; + evaluateOptions = assign({ + 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, {}, {}); + } + }, evaluateOptions || {}); + var aClauseProps = this.getClauseProperties(a, aOptions), bClauseProps = this.getClauseProperties(b, bOptions), set = {}, useSet; + var result = evaluateOptions.evaluateWhere(aClauseProps.where, bClauseProps.where, undefined, undefined, undefined, this.clauses.where, {}); + useSet = this.updateSet(set, 'where', result, useSet); + if (result && evaluateOptions.shouldEvaluatePaginate(aClauseProps, bClauseProps)) { + if (evaluateOptions.shouldEvaluateOrder(aClauseProps, bClauseProps)) { + result = evaluateOptions.evaluateOrder(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {}); + useSet = this.updateSet(set, 'order', result, useSet); + } + if (result) { + result = evaluateOptions.evaluatePaginate(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, this.clauses.paginate, {}); + useSet = this.updateSet(set, 'paginate', result, useSet); + } + } else if (result && evaluateOptions.shouldEvaluateOrder(aClauseProps, bClauseProps)) { + result = operator(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {}); + useSet = this.updateSet(set, 'order', result, useSet); + } + return result && useSet ? set : result; + }, + equal: function (a, b) { + return this.evaluateOperator(compare.equal, a, b); + }, + subset: function (a, b) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var compatibleSort = true; + var result; + if (bClauseProps.enabled.paginate && (aClauseProps.enabled.order || bClauseProps.enabled.order)) { + compatibleSort = compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {}); + } + if (!compatibleSort) { + result = false; + } else { + result = this.evaluateOperator(compare.subset, a, b); + } + return result; + }, + properSubset: function (a, b) { + return this.subset(a, b) && !this.equal(a, b); + }, + difference: function (a, b) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var differentClauses = this.getDifferentClauseTypes(aClauseProps, bClauseProps); + var clause, result; + if (differentClauses.length > 2) { + result = false; + } else if (differentClauses.length === 2 && (differentClauses[0] !== 'where' || differentClauses[1] !== 'id')) { + result = false; + } else { + switch (clause = differentClauses[0]) { + case undefined: + case 'order': { + result = false; + break; + } + case 'paginate': + case 'where': { + result = compare.difference(aClauseProps[clause], bClauseProps[clause], undefined, undefined, undefined, this.clauses[clause], {}); + if (typeof result === 'object') { + if (this.translators[clause]) { + result = this.translators[clause].toSet({}, result); + } + assign(result, aClauseProps.order); + if (clause === 'paginate') { + assign(result, aClauseProps.where); + } else if (differentClauses[1] === 'id') { + result = compare.difference(aClauseProps.id, bClauseProps.id, undefined, undefined, undefined, this.clauses.id, {}); + } + } + break; + } + } + } + return result; + }, + union: function (a, b) { + return this.evaluateOperator(compare.union, a, b); + }, + intersection: function (a, b) { + return this.evaluateOperator(compare.intersection, a, b); + }, + count: function (set) { + return this.evaluateOperator(compare.count, set, {}); + }, + has: function (set, props) { + var result = this.evaluateOperator(compare.subset, props, set, { isProperties: true }, undefined, { + shouldEvaluatePaginate: function () { + return false; + } + }); + return result; + }, + index: function (set, items, item) { + var aClauseProps = this.getClauseProperties(set); + var propName = h.firstProp(aClauseProps.order), compare, orderValue; + if (propName) { + compare = this.clauses.order[propName]; + orderValue = set[propName]; + return h.index(function (itemA, itemB) { + return compare(orderValue, itemA, itemB); + }, items, item); + } + propName = h.firstProp(this.clauses.id); + if (propName) { + compare = h.defaultSort; + orderValue = propName; + return h.index(function (itemA, itemB) { + return compare(orderValue, itemA, itemB); + }, items, item); + } + return; + }, + getSubset: function (a, b, bData) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var isSubset = this.subset(assign({}, aClauseProps.where, aClauseProps.paginate), assign({}, bClauseProps.where, bClauseProps.paginate)); + if (isSubset) { + return get.subsetData(a, b, bData, this); + } + }, + getUnion: function (a, b, aItems, bItems) { + var aClauseProps = this.getClauseProperties(a); + var bClauseProps = this.getClauseProperties(b); + var algebra = this; + var options; + if (this.subset(a, b)) { + return bItems; + } else if (this.subset(b, a)) { + return aItems; + } + var combined; + if (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate) { + options = {}; + var isUnion = compare.union(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, this.clauses.paginate, options); + if (!isUnion) { + return; + } else { + each(options.getUnions, function (filter) { + var items = filter(a, b, aItems, bItems, algebra, options); + aItems = items[0]; + bItems = items[1]; + }); + combined = concatUnique(aItems, bItems, this); + } + } else { + combined = concatUnique(aItems, bItems, this); + } + if (combined.length && aClauseProps.enabled.order && compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {})) { + options = {}; + var propName = h.firstProp(aClauseProps.order), compareOrder = algebra.clauses.order[propName]; + combined = combined.sort(function (aItem, bItem) { + return compareOrder(a[propName], aItem, bItem); + }); + } + return combined; + }, + id: function (props) { + var keys = Object.keys(this.clauses.id); + if (keys.length === 1) { + return props[keys[0]]; + } else { + var id = {}; + keys.forEach(function (key) { + id[key] = props[key]; + }); + return JSON.stringify(id); + } + } + }); + var callOnAlgebra = function (methodName, algebraArgNumber) { + return function () { + var args = makeArray(arguments).slice(0, algebraArgNumber); + var algebra = Algebra.make(arguments[algebraArgNumber]); + return algebra[methodName].apply(algebra, args); + }; + }; + module.exports = { + Algebra: Algebra, + Translate: Translate, + difference: callOnAlgebra('difference', 2), + equal: callOnAlgebra('equal', 2), + subset: callOnAlgebra('subset', 2), + properSubset: callOnAlgebra('properSubset', 2), + union: callOnAlgebra('union', 2), + intersection: callOnAlgebra('intersection', 2), + count: callOnAlgebra('count', 1), + has: callOnAlgebra('has', 2), + index: callOnAlgebra('index', 3), + getSubset: callOnAlgebra('getSubset', 3), + getUnion: callOnAlgebra('getUnion', 4) + }; +}); +/*can-set@1.5.2#src/props*/ +define('can-set/src/props', [ + 'require', + 'exports', + 'module', + 'can-set/src/helpers', + 'can-set/src/clause', + 'set-can-util/js/each/each' +], function (require, exports, module) { + 'use strict'; + var h = require('can-set/src/helpers'); + var clause = require('can-set/src/clause'); + var each = require('set-can-util/js/each/each'); + var within = function (value, range) { + return value >= range[0] && value <= range[1]; + }; + var numericProperties = function (setA, setB, property1, property2) { + return { + sAv1: +setA[property1], + sAv2: +setA[property2], + sBv1: +setB[property1], + sBv2: +setB[property2] + }; + }; + var diff = function (setA, setB, property1, property2) { + var numProps = numericProperties(setA, setB, property1, property2); + var sAv1 = numProps.sAv1, sAv2 = numProps.sAv2, sBv1 = numProps.sBv1, sBv2 = numProps.sBv2, count = sAv2 - sAv1 + 1; + var after = { + difference: [ + sBv2 + 1, + sAv2 + ], + intersection: [ + sAv1, + sBv2 + ], + union: [ + sBv1, + sAv2 + ], + count: count, + meta: 'after' + }; + var before = { + difference: [ + sAv1, + sBv1 - 1 + ], + intersection: [ + sBv1, + sAv2 + ], + union: [ + sAv1, + sBv2 + ], + count: count, + meta: 'before' + }; + if (sAv1 === sBv1 && sAv2 === sBv2) { + return { + intersection: [ + sAv1, + sAv2 + ], + union: [ + sAv1, + sAv2 + ], + count: count, + meta: 'equal' + }; + } else if (sAv1 === sBv1 && sBv2 < sAv2) { + return after; + } else if (sAv2 === sBv2 && sBv1 > sAv1) { + return before; + } else if (within(sAv1, [ + sBv1, + sBv2 + ]) && within(sAv2, [ + sBv1, + sBv2 + ])) { + return { + intersection: [ + sAv1, + sAv2 + ], + union: [ + sBv1, + sBv2 + ], + count: count, + meta: 'subset' + }; + } else if (within(sBv1, [ + sAv1, + sAv2 + ]) && within(sBv2, [ + sAv1, + sAv2 + ])) { + return { + intersection: [ + sBv1, + sBv2 + ], + difference: [ + null, + null + ], + union: [ + sAv1, + sAv2 + ], + count: count, + meta: 'superset' + }; + } else if (sAv1 < sBv1 && within(sAv2, [ + sBv1, + sBv2 + ])) { + return before; + } else if (sBv1 < sAv1 && within(sBv2, [ + sAv1, + sAv2 + ])) { + return after; + } else if (sAv2 === sBv1 - 1) { + return { + difference: [ + sAv1, + sAv2 + ], + union: [ + sAv1, + sBv2 + ], + count: count, + meta: 'disjoint-before' + }; + } else if (sBv2 === sAv1 - 1) { + return { + difference: [ + sAv1, + sAv2 + ], + union: [ + sBv1, + sAv2 + ], + count: count, + meta: 'disjoint-after' + }; + } + if (!isNaN(count)) { + return { + count: count, + meta: 'disjoint' + }; + } + }; + var cleanUp = function (value, enumData) { + if (!value) { + return enumData; + } + if (!Array.isArray(value)) { + value = [value]; + } + if (!value.length) { + return enumData; + } + return value; + }; + var stringConvert = { + '0': false, + 'false': false, + 'null': undefined, + 'undefined': undefined + }; + var convertToBoolean = function (value) { + if (typeof value === 'string') { + return value.toLowerCase() in stringConvert ? stringConvert[value.toLowerCase()] : true; + } + return value; + }; + var props = { + 'enum': function (prop, enumData) { + var compares = new clause.Where({}); + compares[prop] = function (vA, vB, A, B) { + vA = cleanUp(vA, enumData); + vB = cleanUp(vB, enumData); + var data = h.arrayUnionIntersectionDifference(vA, vB); + if (!data.difference.length) { + delete data.difference; + } + each(data, function (value, prop) { + if (Array.isArray(value)) { + if (h.arraySame(enumData, value)) { + data[prop] = undefined; + } else if (value.length === 1) { + data[prop] = value[0]; + } + } + }); + return data; + }; + return compares; + }, + paginate: function (propStart, propEnd, translateToStartEnd, reverseTranslate) { + var compares = {}; + var makeResult = function (result, index) { + var res = {}; + each([ + 'intersection', + 'difference', + 'union' + ], function (prop) { + if (result[prop]) { + var set = { + start: result[prop][0], + end: result[prop][1] + }; + res[prop] = reverseTranslate(set)[index === 0 ? propStart : propEnd]; + } + }); + if (result.count) { + res.count = result.count; + } + return res; + }; + compares[propStart] = function (vA, vB, A, B) { + if (vA === undefined) { + return; + } + var res = diff(translateToStartEnd(A), translateToStartEnd(B), 'start', 'end'); + var result = makeResult(res, 0); + result.getSubset = function (a, b, bItems, algebra, options) { + return bItems; + }; + result.getUnion = function (a, b, aItems, bItems, algebra, options) { + return [ + aItems, + bItems + ]; + }; + return result; + }; + compares[propEnd] = function (vA, vB, A, B) { + if (vA === undefined) { + return; + } + var data = diff(translateToStartEnd(A), translateToStartEnd(B), 'start', 'end'); + var res = makeResult(data, 1); + res.getSubset = function (a, b, bItems, algebra, options) { + var tA = translateToStartEnd(a); + var tB = translateToStartEnd(b); + var numProps = numericProperties(tA, tB, 'start', 'end'); + var aStartValue = numProps.sAv1, aEndValue = numProps.sAv2; + var bStartValue = numProps.sBv1; + if (!('end' in tB) || !('end' in tA)) { + return bItems.slice(aStartValue, aEndValue + 1); + } + return bItems.slice(aStartValue - bStartValue, aEndValue - bStartValue + 1); + }; + res.getUnion = function (a, b, aItems, bItems, algebra, options) { + var tA = translateToStartEnd(a); + var tB = translateToStartEnd(b); + if (data.meta.indexOf('after') >= 0) { + if (data.intersection) { + bItems = bItems.slice(0, data.intersection[0] - +tB.start); + } + return [ + bItems, + aItems + ]; + } + if (data.intersection) { + aItems = aItems.slice(0, data.intersection[0] - +tA.start); + } + return [ + aItems, + bItems + ]; + }; + return res; + }; + return new clause.Paginate(compares); + }, + 'boolean': function (propertyName) { + var compares = new clause.Where({}); + compares[propertyName] = function (propA, propB) { + propA = convertToBoolean(propA); + propB = convertToBoolean(propB); + var notA = !propA, notB = !propB; + if (propA === notB && propB === notA) { + return { + difference: !propB, + union: undefined + }; + } else if (propA === undefined) { + return { + difference: !propB, + intersection: propB, + union: undefined + }; + } else if (propA === propB) { + return true; + } + }; + return compares; + }, + 'sort': function (prop, sortFunc) { + if (!sortFunc) { + sortFunc = h.defaultSort; + } + var compares = {}; + compares[prop] = sortFunc; + return new clause.Order(compares); + }, + 'id': function (prop) { + var compares = {}; + compares[prop] = prop; + return new clause.Id(compares); + } + }; + var assignExcept = function (d, s, props) { + for (var prop in s) { + if (!props[prop]) { + d[prop] = s[prop]; + } + } + return d; + }; + var translateToOffsetLimit = function (set, offsetProp, limitProp) { + var newSet = assignExcept({}, set, { + start: 1, + end: 1 + }); + if ('start' in set) { + newSet[offsetProp] = set.start; + } + if ('end' in set) { + newSet[limitProp] = set.end - set.start + 1; + } + return newSet; + }; + var translateToStartEnd = function (set, offsetProp, limitProp) { + var except = {}; + except[offsetProp] = except[limitProp] = 1; + var newSet = assignExcept({}, set, except); + if (offsetProp in set) { + newSet.start = parseInt(set[offsetProp], 10); + } + if (limitProp in set) { + newSet.end = newSet.start + parseInt(set[limitProp]) - 1; + } + return newSet; + }; + props.offsetLimit = function (offsetProp, limitProp) { + offsetProp = offsetProp || 'offset'; + limitProp = limitProp || 'limit'; + return props.paginate(offsetProp, limitProp, function (set) { + return translateToStartEnd(set, offsetProp, limitProp); + }, function (set) { + return translateToOffsetLimit(set, offsetProp, limitProp); + }); + }; + props.rangeInclusive = function (startIndexProperty, endIndexProperty) { + startIndexProperty = startIndexProperty || 'start'; + endIndexProperty = endIndexProperty || 'end'; + return props.paginate(startIndexProperty, endIndexProperty, function (set) { + var except = {}; + except[startIndexProperty] = except[endIndexProperty] = 1; + var newSet = assignExcept({}, set, except); + if (startIndexProperty in set) { + newSet.start = set[startIndexProperty]; + } + if (endIndexProperty in set) { + newSet.end = set[endIndexProperty]; + } + return newSet; + }, function (set) { + var except = { + start: 1, + end: 1 + }; + var newSet = assignExcept({}, set, except); + newSet[startIndexProperty] = set.start; + newSet[endIndexProperty] = set.end; + return newSet; + }); + }; + var nestedLookup = function (obj, propNameArray) { + if (obj === undefined) { + return undefined; + } + if (propNameArray.length === 1) { + return obj[propNameArray[0]]; + } else { + return nestedLookup(obj[propNameArray[0]], propNameArray.slice(1)); + } + }; + props.dotNotation = function (dotProperty) { + var compares = new clause.Where({}); + compares[dotProperty] = function (aVal, bVal, a, b, propertyName) { + if (aVal === undefined) { + aVal = nestedLookup(a, propertyName.split('.')); + } + if (bVal === undefined) { + bVal = nestedLookup(b, propertyName.split('.')); + } + return aVal === bVal; + }; + return compares; + }; + module.exports = props; +}); +/*can-set@1.5.2#src/set*/ +define('can-set', [ + 'require', + 'exports', + 'module', + 'can-set/src/set-core', + 'can-namespace', + 'can-set/src/props', + 'can-set/src/clause', + 'can-set/src/helpers' +], function (require, exports, module) { + 'use strict'; + var set = require('can-set/src/set-core'); + var ns = require('can-namespace'); + var props = require('can-set/src/props'); + var clause = require('can-set/src/clause'); + set.comparators = props; + set.props = props; + set.helpers = require('can-set/src/helpers'); + set.clause = clause; + module.exports = ns.set = set; +}); +/*[global-shim-end]*/ +(function(global) { // jshint ignore:line + global._define = global.define; + global.define = global.define.orig; +} +)(typeof self == "object" && self.Object == Object ? self : (typeof process === "object" && Object.prototype.toString.call(process) === "[object process]") ? global : window); \ No newline at end of file