@calcit/procs
Advanced tools
Comparing version 0.2.56 to 0.2.58
@@ -135,4 +135,14 @@ import * as ternaryTree from "@calcit/ternary-tree"; | ||
append(v) { | ||
this.turnListMode(); | ||
return new CrDataList(ternaryTree.append(this.value, v)); | ||
if (this.arrayMode && this.arrayEnd === this.arrayValue.length) { | ||
// dirty trick to reuse list memory, data storage actually appended at existing array | ||
this.arrayValue.push(v); | ||
let newList = new CrDataList(this.arrayValue); | ||
newList.arrayStart = this.arrayStart; | ||
newList.arrayEnd = this.arrayEnd + 1; | ||
return newList; | ||
} | ||
else { | ||
this.turnListMode(); | ||
return new CrDataList(ternaryTree.append(this.value, v)); | ||
} | ||
} | ||
@@ -139,0 +149,0 @@ prepend(v) { |
@@ -180,4 +180,13 @@ import * as ternaryTree from "@calcit/ternary-tree"; | ||
append(v: CrDataValue) { | ||
this.turnListMode(); | ||
return new CrDataList(ternaryTree.append(this.value, v)); | ||
if (this.arrayMode && this.arrayEnd === this.arrayValue.length) { | ||
// dirty trick to reuse list memory, data storage actually appended at existing array | ||
this.arrayValue.push(v); | ||
let newList = new CrDataList(this.arrayValue); | ||
newList.arrayStart = this.arrayStart; | ||
newList.arrayEnd = this.arrayEnd + 1; | ||
return newList; | ||
} else { | ||
this.turnListMode(); | ||
return new CrDataList(ternaryTree.append(this.value, v)); | ||
} | ||
} | ||
@@ -184,0 +193,0 @@ prepend(v: CrDataValue) { |
@@ -238,2 +238,31 @@ var _a; | ||
if (typeof xs === "string") { | ||
if (typeof x != "number") { | ||
throw new Error("Expected number index for detecting"); | ||
} | ||
let size = xs.length; | ||
if (x >= 0 && x < size) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (xs instanceof CrDataList) { | ||
if (typeof x != "number") { | ||
throw new Error("Expected number index for detecting"); | ||
} | ||
let size = xs.len(); | ||
if (x >= 0 && x < size) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (xs instanceof CrDataMap) { | ||
return xs.contains(x); | ||
} | ||
if (xs instanceof CrDataSet) { | ||
throw new Error("Set expected `includes?` for detecting"); | ||
} | ||
throw new Error("`contains?` expected a structure"); | ||
}; | ||
export let includes_QUES_ = (xs, x) => { | ||
if (typeof xs === "string") { | ||
if (typeof x !== "string") { | ||
@@ -254,3 +283,8 @@ throw new Error("Expected string"); | ||
if (xs instanceof CrDataMap) { | ||
return xs.contains(x); | ||
for (let [k, v] of xs.pairs()) { | ||
if (_AND__EQ_(v, x)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
@@ -260,3 +294,3 @@ if (xs instanceof CrDataSet) { | ||
} | ||
throw new Error("Does not support contains? on this type"); | ||
throw new Error("includes? expected a structure"); | ||
}; | ||
@@ -263,0 +297,0 @@ export let get = function (xs, k) { |
@@ -274,2 +274,33 @@ import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree"; | ||
if (typeof xs === "string") { | ||
if (typeof x != "number") { | ||
throw new Error("Expected number index for detecting"); | ||
} | ||
let size = xs.length; | ||
if (x >= 0 && x < size) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (xs instanceof CrDataList) { | ||
if (typeof x != "number") { | ||
throw new Error("Expected number index for detecting"); | ||
} | ||
let size = xs.len(); | ||
if (x >= 0 && x < size) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (xs instanceof CrDataMap) { | ||
return xs.contains(x); | ||
} | ||
if (xs instanceof CrDataSet) { | ||
throw new Error("Set expected `includes?` for detecting"); | ||
} | ||
throw new Error("`contains?` expected a structure"); | ||
}; | ||
export let includes_QUES_ = (xs: CrDataValue, x: CrDataValue): boolean => { | ||
if (typeof xs === "string") { | ||
if (typeof x !== "string") { | ||
@@ -290,3 +321,8 @@ throw new Error("Expected string"); | ||
if (xs instanceof CrDataMap) { | ||
return xs.contains(x); | ||
for (let [k, v] of xs.pairs()) { | ||
if (_AND__EQ_(v, x)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
@@ -297,3 +333,3 @@ if (xs instanceof CrDataSet) { | ||
throw new Error("Does not support contains? on this type"); | ||
throw new Error("includes? expected a structure"); | ||
}; | ||
@@ -300,0 +336,0 @@ |
{ | ||
"name": "@calcit/procs", | ||
"version": "0.2.56", | ||
"version": "0.2.58", | ||
"main": "./lib/calcit.procs.js", | ||
@@ -16,5 +16,5 @@ "devDependencies": { | ||
"dependencies": { | ||
"@calcit/ternary-tree": "0.0.7", | ||
"@calcit/ternary-tree": "0.0.9", | ||
"@cirru/parser.ts": "^0.0.1" | ||
} | ||
} |
99928
3714
+ Added@calcit/ternary-tree@0.0.9(transitive)
- Removed@calcit/ternary-tree@0.0.7(transitive)
Updated@calcit/ternary-tree@0.0.9