Skip to content

Commit 0ae662c

Browse files
committed
feat: add BigInt support for indexing and search
Closes #814
1 parent 8153c9d commit 0ae662c

11 files changed

Lines changed: 45 additions & 9 deletions

File tree

dist/fuse.basic.cjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function baseToString(value) {
1717
if (typeof value == 'string') {
1818
return value;
1919
}
20+
if (typeof value === 'bigint') {
21+
return value.toString();
22+
}
2023
const result = value + '';
2124
return result == '0' && 1 / value == -Infinity ? '-0' : result;
2225
}
@@ -155,7 +158,7 @@ function get(obj, path) {
155158

156159
// If we're at the last value in the path, and if it's a string/number/bool,
157160
// add it to the list
158-
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
161+
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === 'bigint')) {
159162
list.push(arrayIndex !== undefined ? {
160163
v: toString(value),
161164
i: arrayIndex

dist/fuse.basic.min.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.basic.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.basic.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ function baseToString(value) {
1515
if (typeof value == 'string') {
1616
return value;
1717
}
18+
if (typeof value === 'bigint') {
19+
return value.toString();
20+
}
1821
const result = value + '';
1922
return result == '0' && 1 / value == -Infinity ? '-0' : result;
2023
}
@@ -153,7 +156,7 @@ function get(obj, path) {
153156

154157
// If we're at the last value in the path, and if it's a string/number/bool,
155158
// add it to the list
156-
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
159+
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === 'bigint')) {
157160
list.push(arrayIndex !== undefined ? {
158161
v: toString(value),
159162
i: arrayIndex

dist/fuse.cjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function baseToString(value) {
1717
if (typeof value == 'string') {
1818
return value;
1919
}
20+
if (typeof value === 'bigint') {
21+
return value.toString();
22+
}
2023
const result = value + '';
2124
return result == '0' && 1 / value == -Infinity ? '-0' : result;
2225
}
@@ -152,7 +155,7 @@ function get(obj, path) {
152155

153156
// If we're at the last value in the path, and if it's a string/number/bool,
154157
// add it to the list
155-
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
158+
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === 'bigint')) {
156159
list.push(arrayIndex !== undefined ? {
157160
v: toString(value),
158161
i: arrayIndex

dist/fuse.min.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ function baseToString(value) {
1515
if (typeof value == 'string') {
1616
return value;
1717
}
18+
if (typeof value === 'bigint') {
19+
return value.toString();
20+
}
1821
const result = value + '';
1922
return result == '0' && 1 / value == -Infinity ? '-0' : result;
2023
}
@@ -150,7 +153,7 @@ function get(obj, path) {
150153

151154
// If we're at the last value in the path, and if it's a string/number/bool,
152155
// add it to the list
153-
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
156+
if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === 'bigint')) {
154157
list.push(arrayIndex !== undefined ? {
155158
v: toString(value),
156159
i: arrayIndex

src/helpers/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function get(obj: any, path: string | string[]): any {
3131
// add it to the list
3232
if (
3333
index === path.length - 1 &&
34-
(isString(value) || isNumber(value) || isBoolean(value))
34+
(isString(value) || isNumber(value) || isBoolean(value) || typeof value === 'bigint')
3535
) {
3636
list.push(
3737
arrayIndex !== undefined

src/helpers/typeGuards.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export function baseToString(value: unknown): string {
1111
if (typeof value == 'string') {
1212
return value
1313
}
14+
if (typeof value === 'bigint') {
15+
return value.toString()
16+
}
1417
const result = value + ''
1518
return result == '0' && 1 / (value as number) == -INFINITY ? '-0' : result
1619
}

0 commit comments

Comments
 (0)