mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
// Ported from js-yaml v3.13.1:
|
|
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
export function isNothing(subject) {
|
|
return typeof subject === "undefined" || subject === null;
|
|
}
|
|
export function isArray(value) {
|
|
return Array.isArray(value);
|
|
}
|
|
export function isBoolean(value) {
|
|
return typeof value === "boolean" || value instanceof Boolean;
|
|
}
|
|
export function isNull(value) {
|
|
return value === null;
|
|
}
|
|
export function isNumber(value) {
|
|
return typeof value === "number" || value instanceof Number;
|
|
}
|
|
export function isString(value) {
|
|
return typeof value === "string" || value instanceof String;
|
|
}
|
|
export function isSymbol(value) {
|
|
return typeof value === "symbol";
|
|
}
|
|
export function isUndefined(value) {
|
|
return value === undefined;
|
|
}
|
|
export function isObject(value) {
|
|
return value !== null && typeof value === "object";
|
|
}
|
|
export function isError(e) {
|
|
return e instanceof Error;
|
|
}
|
|
export function isFunction(value) {
|
|
return typeof value === "function";
|
|
}
|
|
export function isRegExp(value) {
|
|
return value instanceof RegExp;
|
|
}
|
|
export function toArray(sequence) {
|
|
if (isArray(sequence))
|
|
return sequence;
|
|
if (isNothing(sequence))
|
|
return [];
|
|
return [sequence];
|
|
}
|
|
export function repeat(str, count) {
|
|
let result = "";
|
|
for (let cycle = 0; cycle < count; cycle++) {
|
|
result += str;
|
|
}
|
|
return result;
|
|
}
|
|
export function isNegativeZero(i) {
|
|
return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;
|
|
}
|