From a7da246e1c3d68313cba2a4775d353b9bd36e140 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Tue, 29 Nov 2022 20:08:03 -0500 Subject: [PATCH 01/16] Add empty string and NaN checks to null filter --- src/table.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/table.js b/src/table.js index 247fd4fc..6ba29e5e 100644 --- a/src/table.js +++ b/src/table.js @@ -532,11 +532,17 @@ export function __table(source, operations) { break; } case "n": { - source = source.filter((d) => d[column] == null); + source = source.filter( + (d) => + d[column] == null || d[column] === "" || Number.isNaN(d[column]) + ); break; } case "nn": { - source = source.filter((d) => d[column] != null); + source = source.filter( + (d) => + d[column] != null && d[column] !== "" && !Number.isNaN(d[column]) + ); break; } case "lt": { From 6358131311ef277534c9776b2eeca66379e29bf7 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 1 Dec 2022 12:36:56 -0500 Subject: [PATCH 02/16] Add filters for defined and not defined --- src/table.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/table.js b/src/table.js index 6ba29e5e..cec86518 100644 --- a/src/table.js +++ b/src/table.js @@ -388,6 +388,8 @@ function appendWhereEntry({type, operands}, args, escaper) { case "nn": appendSql(` IS NOT NULL`, args); return; + // TODO: case "d" (defined) and case "nd" not defined + // Something like - (x IS NULL OR x = '' OR x = float 'NaN') default: throw new Error("Invalid filter operation"); } @@ -532,13 +534,21 @@ export function __table(source, operations) { break; } case "n": { + source = source.filter((d) => d[column] == null); + break; + } + case "nn": { + source = source.filter((d) => d[column] != null); + break; + } + case "nd": { source = source.filter( (d) => d[column] == null || d[column] === "" || Number.isNaN(d[column]) ); break; } - case "nn": { + case "d": { source = source.filter( (d) => d[column] != null && d[column] !== "" && !Number.isNaN(d[column]) From b701de1e3042fe8ac3ef338554127aaf586a1776 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Tue, 6 Dec 2022 13:36:13 -0500 Subject: [PATCH 03/16] Only check that the first value is a primitive type --- src/table.js | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/table.js b/src/table.js index cec86518..6f4f193d 100644 --- a/src/table.js +++ b/src/table.js @@ -83,48 +83,29 @@ export function arrayIsPrimitive(value) { ); } -// Given an array, checks that the first n elements are primitives (number, -// string, boolean, bigint) of a consistent type. +// Given an array, checks that one of the first n elements is a primitive function arrayContainsPrimitives(value) { const n = Math.min(nChecks, value.length); + const primitives = ["number", "boolean", "string", "bigint"]; if (!(n > 0)) return false; - let type; - let hasPrimitive = false; // ensure we encounter 1+ primitives for (let i = 0; i < n; ++i) { const v = value[i]; if (v == null) continue; // ignore null and undefined - const t = typeof v; - if (type === undefined) { - switch (t) { - case "number": - case "boolean": - case "string": - case "bigint": - type = t; - break; - default: - return false; - } - } else if (t !== type) { - return false; - } - hasPrimitive = true; + return primitives.includes(typeof v); } - return hasPrimitive; + return false; } -// Given an array, checks that the first n elements are dates. +// Given an array, checks that the first of n elements is a date function arrayContainsDates(value) { const n = Math.min(nChecks, value.length); if (!(n > 0)) return false; - let hasDate = false; // ensure we encounter 1+ dates for (let i = 0; i < n; ++i) { const v = value[i]; if (v == null) continue; // ignore null and undefined - if (!(v instanceof Date)) return false; - hasDate = true; + return v instanceof Date && !Number.isNaN(+v); } - return hasDate; + return false; } function isTypedArray(value) { From 318c2803510d32b4432df074c69b629850ee3319 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Tue, 6 Dec 2022 16:58:32 -0500 Subject: [PATCH 04/16] Add valid and not valid filters --- src/table.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/table.js b/src/table.js index 6f4f193d..0b7dfd76 100644 --- a/src/table.js +++ b/src/table.js @@ -475,6 +475,19 @@ export function __table(source, operations) { const [{value: column}] = operands; const values = operands.slice(1).map(({value}) => value); switch (type) { + // valid (matches the column type) + case "v": { + const [colType] = values; + source = source.filter((d) => typeof d[column] === colType); + break; + } + // not valid (doesn't match the column type) + case "nv": { + const [colType] = values; + source = source.filter((d) => typeof d[column] !== colType); + break; + } + // TODO: not valid / valid for dates case "eq": { const [value] = values; if (value instanceof Date) { From 2b13fe41cb4314e62e66f3ed281abe7f52983dfc Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Wed, 7 Dec 2022 15:27:13 -0500 Subject: [PATCH 05/16] Add filters for dates --- src/table.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/table.js b/src/table.js index 0b7dfd76..b374c1f8 100644 --- a/src/table.js +++ b/src/table.js @@ -478,16 +478,21 @@ export function __table(source, operations) { // valid (matches the column type) case "v": { const [colType] = values; - source = source.filter((d) => typeof d[column] === colType); + const filter = colType === "date" ? + (d) => (d[column] instanceof Date) && !Number.isNaN(+d[column]) : + (d) => typeof d[column] === colType; + source = source.filter(filter); break; } // not valid (doesn't match the column type) case "nv": { const [colType] = values; - source = source.filter((d) => typeof d[column] !== colType); + const filter = colType === "date" ? + (d) => !(d[column] instanceof Date) || Number.isNaN(+d[column]) : + (d) => typeof d[column] !== colType; + source = source.filter(filter); break; } - // TODO: not valid / valid for dates case "eq": { const [value] = values; if (value instanceof Date) { From 738cd97145e2b56d95b396a3d6831c5d858ecb10 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 10:10:01 -0500 Subject: [PATCH 06/16] Add isValid function and export it --- src/index.js | 3 ++- src/table.js | 31 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 29751825..730434af 100644 --- a/src/index.js +++ b/src/index.js @@ -7,5 +7,6 @@ export { arrayIsPrimitive, isDataArray, isDatabaseClient, - __table as applyDataTableOperations + __table as applyDataTableOperations, + isValid } from "./table.js"; diff --git a/src/table.js b/src/table.js index b374c1f8..afb1ada9 100644 --- a/src/table.js +++ b/src/table.js @@ -462,6 +462,27 @@ function likeOperand(operand) { return {...operand, value: `%${operand.value}%`}; } +// Check if a value is a valid form of the column type +export function isValid(value, colType) { + switch (colType) { + case "string": + case "bigint": + case "boolean": + return typeof value === colType; + case "number": + return typeof value === colType && !Number.isNaN(value); + case "date": + return value instanceof Date && !isNaN(value); + case "buffer": + return value instanceof ArrayBuffer; + case "array": + return Array.isArray(value); + case "object": + return typeof value === colType && value !== null; + case "other": + return value != null; + } +} // This function applies table cell operations to an in-memory table (array of // objects); it should be equivalent to the corresponding SQL query. TODO Use // DuckDBClient for data arrays, too, and then we wouldn’t need our own __table @@ -478,19 +499,13 @@ export function __table(source, operations) { // valid (matches the column type) case "v": { const [colType] = values; - const filter = colType === "date" ? - (d) => (d[column] instanceof Date) && !Number.isNaN(+d[column]) : - (d) => typeof d[column] === colType; - source = source.filter(filter); + source = source.filter(d => isValid(d, colType)); break; } // not valid (doesn't match the column type) case "nv": { const [colType] = values; - const filter = colType === "date" ? - (d) => !(d[column] instanceof Date) || Number.isNaN(+d[column]) : - (d) => typeof d[column] !== colType; - source = source.filter(filter); + source = source.filter(d => !isValid(d, colType)); break; } case "eq": { From 468950685b5827b8dae4348a9acdc4baae8c4de6 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 10:48:55 -0500 Subject: [PATCH 07/16] Pass the correct value to isValid --- .prettierignore | 1 + src/table.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..fa29cdff --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +** \ No newline at end of file diff --git a/src/table.js b/src/table.js index afb1ada9..bdb62a3f 100644 --- a/src/table.js +++ b/src/table.js @@ -499,13 +499,13 @@ export function __table(source, operations) { // valid (matches the column type) case "v": { const [colType] = values; - source = source.filter(d => isValid(d, colType)); + source = source.filter(d => isValid(d[column], colType)); break; } // not valid (doesn't match the column type) case "nv": { const [colType] = values; - source = source.filter(d => !isValid(d, colType)); + source = source.filter(d => !isValid(d[column], colType)); break; } case "eq": { From ff247450511ea304481cae381557a4a1ec4068e7 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 12:14:43 -0500 Subject: [PATCH 08/16] Remove unused nd and d filters --- src/table.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/table.js b/src/table.js index bdb62a3f..ec5c966b 100644 --- a/src/table.js +++ b/src/table.js @@ -555,20 +555,6 @@ export function __table(source, operations) { source = source.filter((d) => d[column] != null); break; } - case "nd": { - source = source.filter( - (d) => - d[column] == null || d[column] === "" || Number.isNaN(d[column]) - ); - break; - } - case "d": { - source = source.filter( - (d) => - d[column] != null && d[column] !== "" && !Number.isNaN(d[column]) - ); - break; - } case "lt": { const [value] = values; source = source.filter((d) => d[column] < value); From 695005385df3e03c5e2ef581327c0c445f3634de Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 12:15:09 -0500 Subject: [PATCH 09/16] Remove prettierignore file --- .prettierignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index fa29cdff..00000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -** \ No newline at end of file From 1f38439faeff39011751c5894d4a3a13e72ac78b Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 12:16:41 -0500 Subject: [PATCH 10/16] Revert "Only check that the first value is a primitive type" This reverts commit b701de1e3042fe8ac3ef338554127aaf586a1776. --- src/table.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/table.js b/src/table.js index ec5c966b..be6af714 100644 --- a/src/table.js +++ b/src/table.js @@ -83,29 +83,48 @@ export function arrayIsPrimitive(value) { ); } -// Given an array, checks that one of the first n elements is a primitive +// Given an array, checks that the first n elements are primitives (number, +// string, boolean, bigint) of a consistent type. function arrayContainsPrimitives(value) { const n = Math.min(nChecks, value.length); - const primitives = ["number", "boolean", "string", "bigint"]; if (!(n > 0)) return false; + let type; + let hasPrimitive = false; // ensure we encounter 1+ primitives for (let i = 0; i < n; ++i) { const v = value[i]; if (v == null) continue; // ignore null and undefined - return primitives.includes(typeof v); + const t = typeof v; + if (type === undefined) { + switch (t) { + case "number": + case "boolean": + case "string": + case "bigint": + type = t; + break; + default: + return false; + } + } else if (t !== type) { + return false; + } + hasPrimitive = true; } - return false; + return hasPrimitive; } -// Given an array, checks that the first of n elements is a date +// Given an array, checks that the first n elements are dates. function arrayContainsDates(value) { const n = Math.min(nChecks, value.length); if (!(n > 0)) return false; + let hasDate = false; // ensure we encounter 1+ dates for (let i = 0; i < n; ++i) { const v = value[i]; if (v == null) continue; // ignore null and undefined - return v instanceof Date && !Number.isNaN(+v); + if (!(v instanceof Date)) return false; + hasDate = true; } - return false; + return hasDate; } function isTypedArray(value) { From f6f1b1215b42304684449be5f7ac76bdfe07765c Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 13:21:46 -0500 Subject: [PATCH 11/16] Remove old comment --- src/table.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/table.js b/src/table.js index be6af714..56aaa550 100644 --- a/src/table.js +++ b/src/table.js @@ -388,8 +388,6 @@ function appendWhereEntry({type, operands}, args, escaper) { case "nn": appendSql(` IS NOT NULL`, args); return; - // TODO: case "d" (defined) and case "nd" not defined - // Something like - (x IS NULL OR x = '' OR x = float 'NaN') default: throw new Error("Invalid filter operation"); } From f38607039f6fbdb744bcdd76fa2641e477b1b686 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Thu, 8 Dec 2022 16:20:45 -0500 Subject: [PATCH 12/16] Extract validators into separate functions to avoid redundant checks --- src/index.js | 2 +- src/table.js | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/index.js b/src/index.js index 730434af..add34363 100644 --- a/src/index.js +++ b/src/index.js @@ -8,5 +8,5 @@ export { isDataArray, isDatabaseClient, __table as applyDataTableOperations, - isValid + getValidator } from "./table.js"; diff --git a/src/table.js b/src/table.js index 56aaa550..7d551395 100644 --- a/src/table.js +++ b/src/table.js @@ -479,27 +479,42 @@ function likeOperand(operand) { return {...operand, value: `%${operand.value}%`}; } -// Check if a value is a valid form of the column type -export function isValid(value, colType) { +// Functions for checking type validity +const isValidNumber = (value) => typeof value === "number" && !Number.isNaN(value); +const isValidString = (value) => typeof value === "string"; +const isValidBoolean = (value) => typeof value === "boolean"; +const isValidBigint = (value) => typeof value === "bigint"; +const isValidDate = (value) => value instanceof Date && !isNaN(value); +const isValidBuffer = (value) => value instanceof ArrayBuffer; +const isValidArray = (value) => Array.isArray(value); +const isValidObject = (value) => typeof value === "object" && value !== null; +const isValidOther = (value) => value != null; + +// Function to get the correct validity checking function based on type +export function getValidator(colType) { switch (colType) { case "string": + return isValidString; case "bigint": + return isValidBigint; case "boolean": - return typeof value === colType; + return isValidBoolean; case "number": - return typeof value === colType && !Number.isNaN(value); + return isValidNumber; case "date": - return value instanceof Date && !isNaN(value); + return isValidDate; case "buffer": - return value instanceof ArrayBuffer; + return isValidBuffer; case "array": - return Array.isArray(value); + return isValidArray; case "object": - return typeof value === colType && value !== null; + return isValidObject; case "other": - return value != null; + default: + return isValidOther; } } + // This function applies table cell operations to an in-memory table (array of // objects); it should be equivalent to the corresponding SQL query. TODO Use // DuckDBClient for data arrays, too, and then we wouldn’t need our own __table @@ -516,13 +531,15 @@ export function __table(source, operations) { // valid (matches the column type) case "v": { const [colType] = values; - source = source.filter(d => isValid(d[column], colType)); + const isValid = getValidator(colType); + source = source.filter(d => isValid(d[column])); break; } // not valid (doesn't match the column type) case "nv": { const [colType] = values; - source = source.filter(d => !isValid(d[column], colType)); + const isValid = getValidator(colType); + source = source.filter(d => !isValid(d[column])); break; } case "eq": { From 0ac2c9fdeeffa4509ba88d011f21013f37683114 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Mon, 12 Dec 2022 14:35:50 -0500 Subject: [PATCH 13/16] Rename getValidator getTypeValidator --- src/index.js | 2 +- src/table.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index add34363..627f0f67 100644 --- a/src/index.js +++ b/src/index.js @@ -8,5 +8,5 @@ export { isDataArray, isDatabaseClient, __table as applyDataTableOperations, - getValidator + getTypeValidator } from "./table.js"; diff --git a/src/table.js b/src/table.js index 7d551395..6725aa67 100644 --- a/src/table.js +++ b/src/table.js @@ -491,7 +491,7 @@ const isValidObject = (value) => typeof value === "object" && value !== null; const isValidOther = (value) => value != null; // Function to get the correct validity checking function based on type -export function getValidator(colType) { +export function getTypeValidator(colType) { switch (colType) { case "string": return isValidString; @@ -531,14 +531,14 @@ export function __table(source, operations) { // valid (matches the column type) case "v": { const [colType] = values; - const isValid = getValidator(colType); + const isValid = getTypeValidator(colType); source = source.filter(d => isValid(d[column])); break; } // not valid (doesn't match the column type) case "nv": { const [colType] = values; - const isValid = getValidator(colType); + const isValid = getTypeValidator(colType); source = source.filter(d => !isValid(d[column])); break; } From afdf9b74026fa76c8f99922252b863a3f2570392 Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Mon, 12 Dec 2022 15:06:36 -0500 Subject: [PATCH 14/16] Add getValidator tests --- test/table-test.js | 87 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/test/table-test.js b/test/table-test.js index 771b08f9..6363467e 100644 --- a/test/table-test.js +++ b/test/table-test.js @@ -1,4 +1,4 @@ -import {makeQueryTemplate, __table} from "../src/table.js"; +import {getTypeValidator, makeQueryTemplate, __table} from "../src/table.js"; import assert from "assert"; export const EMPTY_TABLE_DATA = { @@ -542,3 +542,88 @@ describe("__table", () => { ); }); }); + +describe("getTypeValidator filters accurately", () => { + let source; + beforeEach(() => { + source = [ + {label: "string", value: "string"}, + {label: "object", value: {}}, + {label: "buffer", value: new ArrayBuffer()}, + {label: "boolean", value: true}, + {label: "array", value: [1, 2, 3]}, + {label: "number", value: 10}, + {label: "date", value: new Date(1)}, + // eslint-disable-next-line no-undef + {label: "bigint", value: BigInt(10)}, + {label: "null", value: null}, + {label: "NaN", value: NaN}, + {label: "undefined"} + ]; + }); + + it("filters strings", () => { + const isValid = getTypeValidator("string"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "string", value: "string"}]); + }); + + it("filters buffers", () => { + const isValid = getTypeValidator("buffer"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "buffer", value: new ArrayBuffer()}]); + }); + + it("filters numbers", () => { + const isValid = getTypeValidator("number"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "number", value: 10}]); + }); + + it("filters booleans", () => { + const isValid = getTypeValidator("boolean"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "boolean", value: true}]); + }); + + it("filters arrays", () => { + const isValid = getTypeValidator("array"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "array", value: [1, 2, 3]}]); + }); + + it("filters dates", () => { + const isValid = getTypeValidator("date"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "date", value: new Date(1)}]); + }); + + it("filters BigInts", () => { + const isValid = getTypeValidator("bigint"); + // eslint-disable-next-line no-undef + assert.deepStrictEqual(source.filter(d => isValid(d.value)), [{label: "bigint", value: BigInt(10)}]); + }); + + it("filters objects", () => { + const isValid = getTypeValidator("object"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), + [ + {label: "object", value: {}}, + {label: "buffer", value: new ArrayBuffer()}, + {label: "array", value: [1, 2, 3]}, + {label: "date", value: new Date(1)}] + ); + }); + + it("filters other", () => { + const isValid = getTypeValidator("other"); + assert.deepStrictEqual(source.filter(d => isValid(d.value)), + [ + {label: "string", value: "string"}, + {label: "object", value: {}}, + {label: "buffer", value: new ArrayBuffer()}, + {label: "boolean", value: true}, + {label: "array", value: [1, 2, 3]}, + {label: "number", value: 10}, + {label: "date", value: new Date(1)}, + // eslint-disable-next-line no-undef + {label: "bigint", value: BigInt(10)}, + {label: "NaN", value: NaN} + ] + ); + }); +}); From d7ac9d8e9e7e2949da6f38f16def5dbdb22337ae Mon Sep 17 00:00:00 2001 From: mkfreeman Date: Mon, 12 Dec 2022 15:13:05 -0500 Subject: [PATCH 15/16] Create null/not null filters for valid/invalid column values --- src/table.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/table.js b/src/table.js index 6725aa67..b0cc96ab 100644 --- a/src/table.js +++ b/src/table.js @@ -397,7 +397,7 @@ function appendWhereEntry({type, operands}, args, escaper) { if (operands.length === 2) { if (["in", "nin"].includes(type)) { // Fallthrough to next parent block. - } else if (["c", "nc"].includes(type)) { + } else if (["c", "nc", "v", "nv"].includes(type)) { // TODO: Case (in)sensitive? appendOperand(operands[0], args, escaper); switch (type) { @@ -407,6 +407,14 @@ function appendWhereEntry({type, operands}, args, escaper) { case "nc": appendSql(` NOT LIKE `, args); break; + // JavaScript "not valid" filter translate to a SQL "IS NULL" + case "nv": + appendSql(` IS NULL`, args); + break; + // JavaScript "valid" filter translate to a SQL "IS NOT NULL" + case "v": + appendSql(` IS NOT NULL`, args); + break; } appendOperand(likeOperand(operands[1]), args, escaper); return; From d3cc14e05158a815072075e540b69adbf5d2949d Mon Sep 17 00:00:00 2001 From: Michael Freeman Date: Mon, 12 Dec 2022 15:21:27 -0500 Subject: [PATCH 16/16] Don't repeatedly re-define source Co-authored-by: Annie Zhang --- test/table-test.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/test/table-test.js b/test/table-test.js index 6363467e..b7b4e870 100644 --- a/test/table-test.js +++ b/test/table-test.js @@ -544,23 +544,20 @@ describe("__table", () => { }); describe("getTypeValidator filters accurately", () => { - let source; - beforeEach(() => { - source = [ - {label: "string", value: "string"}, - {label: "object", value: {}}, - {label: "buffer", value: new ArrayBuffer()}, - {label: "boolean", value: true}, - {label: "array", value: [1, 2, 3]}, - {label: "number", value: 10}, - {label: "date", value: new Date(1)}, - // eslint-disable-next-line no-undef - {label: "bigint", value: BigInt(10)}, - {label: "null", value: null}, - {label: "NaN", value: NaN}, - {label: "undefined"} - ]; - }); + let source = [ + {label: "string", value: "string"}, + {label: "object", value: {}}, + {label: "buffer", value: new ArrayBuffer()}, + {label: "boolean", value: true}, + {label: "array", value: [1, 2, 3]}, + {label: "number", value: 10}, + {label: "date", value: new Date(1)}, + // eslint-disable-next-line no-undef + {label: "bigint", value: BigInt(10)}, + {label: "null", value: null}, + {label: "NaN", value: NaN}, + {label: "undefined"} + ]; it("filters strings", () => { const isValid = getTypeValidator("string");