@bunt/util
Advanced tools
Comparing version 0.29.19 to 0.29.26
@@ -0,5 +1,9 @@ | ||
import { Rec } from "@bunt/type"; | ||
export declare class QueryString { | ||
static parseFieldName: (name: string) => string[]; | ||
static inject: ([key, ...paths]: string[], value: unknown, fields?: any) => any; | ||
#private; | ||
constructor(entries?: [field: string, value: unknown][]); | ||
parseField(name: string): string[]; | ||
push(name: string, value: unknown): Rec; | ||
toObject(): Rec; | ||
} | ||
//# sourceMappingURL=qs.d.ts.map |
@@ -6,9 +6,22 @@ "use strict"; | ||
class QueryString { | ||
static parseFieldName = (name) => { | ||
#value; | ||
constructor(entries = []) { | ||
this.#value = Object.create(null); | ||
for (const [field, value] of entries) { | ||
this.push(field, value); | ||
} | ||
} | ||
parseField(name) { | ||
const base = name.replace(/\[.+/, ""); | ||
return [base, ...[...name.matchAll(/\[([^\]]*)\]/ig)].map(([, key]) => key)]; | ||
}; | ||
static inject = ([key, ...paths], value, fields = {}) => { | ||
} | ||
push(name, value) { | ||
return this.#inject(this.parseField(name), value, this.#value); | ||
} | ||
toObject() { | ||
return this.#value; | ||
} | ||
#inject = ([key, ...paths], value, fields = Object.create(null)) => { | ||
if (paths.length > 0) { | ||
fields[key] = this.inject(paths, value, fields[key]); | ||
fields[key] = this.#inject(paths, value, fields[key]); | ||
} | ||
@@ -15,0 +28,0 @@ else { |
@@ -0,5 +1,9 @@ | ||
import { Rec } from "@bunt/type"; | ||
export declare class QueryString { | ||
static parseFieldName: (name: string) => string[]; | ||
static inject: ([key, ...paths]: string[], value: unknown, fields?: any) => any; | ||
#private; | ||
constructor(entries?: [field: string, value: unknown][]); | ||
parseField(name: string): string[]; | ||
push(name: string, value: unknown): Rec; | ||
toObject(): Rec; | ||
} | ||
//# sourceMappingURL=qs.d.ts.map |
const isNumeric = (key) => !isNaN(+key); | ||
export class QueryString { | ||
static parseFieldName = (name) => { | ||
#value; | ||
constructor(entries = []) { | ||
this.#value = Object.create(null); | ||
for (const [field, value] of entries) { | ||
this.push(field, value); | ||
} | ||
} | ||
parseField(name) { | ||
const base = name.replace(/\[.+/, ""); | ||
return [base, ...[...name.matchAll(/\[([^\]]*)\]/ig)].map(([, key]) => key)]; | ||
}; | ||
static inject = ([key, ...paths], value, fields = {}) => { | ||
} | ||
push(name, value) { | ||
return this.#inject(this.parseField(name), value, this.#value); | ||
} | ||
toObject() { | ||
return this.#value; | ||
} | ||
#inject = ([key, ...paths], value, fields = Object.create(null)) => { | ||
if (paths.length > 0) { | ||
fields[key] = this.inject(paths, value, fields[key]); | ||
fields[key] = this.#inject(paths, value, fields[key]); | ||
} | ||
@@ -11,0 +24,0 @@ else { |
{ | ||
"name": "@bunt/util", | ||
"version": "0.29.19", | ||
"version": "0.29.26", | ||
"keywords": [ | ||
@@ -42,3 +42,3 @@ "typescript" | ||
"license": "MIT", | ||
"gitHead": "878fc8a221c3eb57448495fe4f0c8f50cca2f271" | ||
"gitHead": "f15def8255bafd5231a46aa842f535cb4ee0fbb9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
351379
2373