Comparing version 1.0.0-beta.4 to 1.0.0-beta.5
@@ -44,4 +44,6 @@ "use strict"; | ||
enumerable: false, | ||
configurable: false, | ||
value: true | ||
value: true, | ||
// These next two are set to squeeze out a little more V8 performance | ||
configurable: true, | ||
writable: true | ||
}); | ||
@@ -68,10 +70,10 @@ return node; | ||
} | ||
if (array.length < 1 && !allowZeroLength) { | ||
if (!allowZeroLength && array.length < 1) { | ||
throw debugError(new Error("Expected non-empty array")); | ||
} | ||
array.forEach((entry, idx) => { | ||
if (entry == null) { | ||
throw debugError(new Error(`Array index ${idx} is ${String(entry)}`)); | ||
for (let idx = 0, l = array.length; idx < l; idx++) { | ||
if (array[idx] == null) { | ||
throw debugError(new Error(`Array index ${idx} is ${String(array[idx])}`)); | ||
} | ||
}); | ||
} | ||
return array; | ||
@@ -176,3 +178,4 @@ } | ||
const items = []; | ||
strings.forEach((text, i) => { | ||
for (let i = 0, l = strings.length; i < l; i++) { | ||
const text = strings[i]; | ||
if (typeof text !== "string") { | ||
@@ -193,3 +196,3 @@ throw new Error("sql.query should be used as a template literal, not a function call."); | ||
} | ||
}); | ||
} | ||
return items; | ||
@@ -258,15 +261,17 @@ } | ||
const currentItems = []; | ||
ensureNonEmptyArray(items, true).forEach((rawItem, i) => { | ||
let items /*: SQLNode | SQLQuery */; | ||
ensureNonEmptyArray(items, true); | ||
for (let i = 0, l = items.length; i < l; i++) { | ||
const rawItem = items[i]; | ||
let itemsToAppend /*: SQLNode | SQLQuery */; | ||
if (Array.isArray(rawItem)) { | ||
items = rawItem.map(enforceValidNode); | ||
itemsToAppend = rawItem.map(enforceValidNode); | ||
} else { | ||
items = [enforceValidNode(rawItem)]; | ||
itemsToAppend = [enforceValidNode(rawItem)]; | ||
} | ||
if (i === 0 || !separator) { | ||
currentItems.push(...items); | ||
currentItems.push(...itemsToAppend); | ||
} else { | ||
currentItems.push(makeRawNode(separator), ...items); | ||
currentItems.push(makeRawNode(separator), ...itemsToAppend); | ||
} | ||
}); | ||
} | ||
return currentItems; | ||
@@ -273,0 +278,0 @@ }; |
{ | ||
"name": "pg-sql2", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-beta.5", | ||
"description": "Generate safe Postgres-compliant SQL with tagged template literals", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -47,4 +47,6 @@ "use strict"; | ||
enumerable: false, | ||
configurable: false, | ||
value: true, | ||
// These next two are set to squeeze out a little more V8 performance | ||
configurable: true, | ||
writable: true, | ||
}); | ||
@@ -72,10 +74,12 @@ return node; | ||
} | ||
if (array.length < 1 && !allowZeroLength) { | ||
if (!allowZeroLength && array.length < 1) { | ||
throw debugError(new Error("Expected non-empty array")); | ||
} | ||
array.forEach((entry, idx) => { | ||
if (entry == null) { | ||
throw debugError(new Error(`Array index ${idx} is ${String(entry)}`)); | ||
for (let idx = 0, l = array.length; idx < l; idx++) { | ||
if (array[idx] == null) { | ||
throw debugError( | ||
new Error(`Array index ${idx} is ${String(array[idx])}`) | ||
); | ||
} | ||
}); | ||
} | ||
return array; | ||
@@ -197,3 +201,4 @@ } | ||
const items = []; | ||
strings.forEach((text, i) => { | ||
for (let i = 0, l = strings.length; i < l; i++) { | ||
const text = strings[i]; | ||
if (typeof text !== "string") { | ||
@@ -216,3 +221,3 @@ throw new Error( | ||
} | ||
}); | ||
} | ||
return items; | ||
@@ -282,15 +287,17 @@ } | ||
const currentItems = []; | ||
ensureNonEmptyArray(items, true).forEach((rawItem, i) => { | ||
let items /*: SQLNode | SQLQuery */; | ||
ensureNonEmptyArray(items, true); | ||
for (let i = 0, l = items.length; i < l; i++) { | ||
const rawItem = items[i]; | ||
let itemsToAppend /*: SQLNode | SQLQuery */; | ||
if (Array.isArray(rawItem)) { | ||
items = rawItem.map(enforceValidNode); | ||
itemsToAppend = rawItem.map(enforceValidNode); | ||
} else { | ||
items = [enforceValidNode(rawItem)]; | ||
itemsToAppend = [enforceValidNode(rawItem)]; | ||
} | ||
if (i === 0 || !separator) { | ||
currentItems.push(...items); | ||
currentItems.push(...itemsToAppend); | ||
} else { | ||
currentItems.push(makeRawNode(separator), ...items); | ||
currentItems.push(makeRawNode(separator), ...itemsToAppend); | ||
} | ||
}); | ||
} | ||
return currentItems; | ||
@@ -297,0 +304,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27895
605