Sha256: 011fe49d7adcb3e38af377cafa1c93d550007160634d8e53e9eff393c57bcae1
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
/* This is generated by ts_routes-rails */ export type ScalarType = string | number | boolean; function $buildOptions(options: any, names: string[]): string { if (options) { let anchor = ""; const q = [] as string[]; for (const key of Object.keys(options)) { if (names.indexOf(key) !== -1) { // the key is already consumed continue; } const value = options[key]; if (key === "anchor") { anchor = `#${$encode(value)}`; } else { $buildQuery(q, key, value); } } return (q.length > 0 ? "?" + q.join("&") : "") + anchor; } else { return ""; } } function $buildQuery(q: string[], key: string, value: any) { if ($isScalarType(value)) { q.push(`${$encode(key)}=${$encode(value)}`); } else if (Array.isArray(value)) { for (const v of value) { $buildQuery(q, `${key}[]`, v); } } else if (value != null) { // i.e. non-null, non-scalar, non-array type for (const k of Object.keys(value)) { $buildQuery(q, `${key}[${k}]`, value[k]); } } } function $encode(value: any): string { return encodeURIComponent(value); } function $isScalarType(value: any): value is ScalarType { return ( typeof value === "string" || typeof value === "number" || typeof value === "boolean" ); } function $isPresent(value: any): boolean { return value != null && ("" + value).length > 0; } function $hasPresentOwnProperty(options: any, key: string): boolean { return options && options.hasOwnProperty(key) && $isPresent(options[key]); }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ts_routes-1.0.3 | lib/ts_routes/runtime.ts |
ts_routes-1.0.2 | lib/ts_routes/runtime.ts |
ts_routes-1.0.1 | lib/ts_routes/runtime.ts |