@platform/util.string
Advanced tools
Comparing version 0.4.11 to 0.5.0
import * as str from './str'; | ||
export { str }; | ||
export * from './queryString'; | ||
export * from './types'; |
@@ -1,9 +0,16 @@ | ||
declare type QueryValue = string | boolean; | ||
declare type QueryObject = { | ||
[key: string]: QueryValue | QueryValue[]; | ||
import * as t from './types'; | ||
export * from './types'; | ||
export declare function toObject<T extends t.UrlQueryObject>(href?: string): T; | ||
export declare function valueAsFlag<T>(value?: string | string[] | number | boolean): T; | ||
export declare function isFlag(keys: string | string[] | undefined, query?: t.UrlQuery): boolean; | ||
export declare function build(options?: { | ||
allowNil?: boolean; | ||
}): { | ||
parts: { | ||
key: string; | ||
value?: string | number | boolean | null | undefined; | ||
entry: string; | ||
}[]; | ||
add(key: string, value?: string | number | boolean | null | undefined): any; | ||
toString(): string; | ||
}; | ||
export declare type UrlQuery = Record<string, string | string[] | number | boolean | undefined>; | ||
export declare function toObject<T extends QueryObject>(href?: string): T; | ||
export declare function valueAsFlag<T>(value?: string | string[] | number | boolean): T; | ||
export declare function isFlag(keys: string | string[] | undefined, query?: UrlQuery): boolean; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var common_1 = require("../common"); | ||
@@ -55,1 +56,22 @@ function toObject(href) { | ||
exports.isFlag = isFlag; | ||
function build(options) { | ||
if (options === void 0) { options = {}; } | ||
var allowNil = options.allowNil === undefined ? true : options.allowNil; | ||
var builder = { | ||
parts: [], | ||
add: function (key, value) { | ||
var isNil = value === undefined || value === null; | ||
if (!allowNil && isNil) { | ||
return builder; | ||
} | ||
var entry = isNil ? key : key + "=" + encodeURIComponent(value || ''); | ||
builder.parts = tslib_1.__spreadArrays(builder.parts, [{ key: key, value: value, entry: entry }]); | ||
return builder; | ||
}, | ||
toString: function () { | ||
return builder.parts.length === 0 ? '' : "?" + builder.parts.map(function (p) { return p.entry; }).join('&'); | ||
}, | ||
}; | ||
return builder; | ||
} | ||
exports.build = build; |
@@ -0,1 +1,2 @@ | ||
export * from './types'; | ||
export * from './wildcard'; | ||
@@ -2,0 +3,0 @@ export * from './convert'; |
{ | ||
"name": "@platform/util.string", | ||
"version": "0.4.11", | ||
"version": "0.5.0", | ||
"description": "String helpers.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
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
37617
86
1038