50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.PrimitivePrototype = exports.IterResult = void 0;
|
|
exports.isObject = isObject;
|
|
exports.isPlainObject = isPlainObject;
|
|
exports.isFunction = isFunction;
|
|
exports.isIterable = isIterable;
|
|
exports.isString = isString;
|
|
exports.isNumber = isNumber;
|
|
exports.Null = Null;
|
|
function isObject(value) {
|
|
return typeof value === 'object';
|
|
}
|
|
function isPlainObject(value) {
|
|
return Object.getPrototypeOf(value) === Object.prototype;
|
|
}
|
|
function isFunction(value) {
|
|
return value != null && typeof value === 'function';
|
|
}
|
|
function isIterable(value) {
|
|
return isFunction(value[Symbol.iterator]);
|
|
}
|
|
function isString(value) {
|
|
return typeof value === 'string';
|
|
}
|
|
function isNumber(value) {
|
|
return !isNaN(value);
|
|
}
|
|
class IterResult {
|
|
static Next(value) {
|
|
return { done: false, value };
|
|
}
|
|
static Done() {
|
|
return { done: true, value: undefined };
|
|
}
|
|
}
|
|
exports.IterResult = IterResult;
|
|
function Null(...args) {
|
|
return null;
|
|
}
|
|
exports.PrimitivePrototype = Object.freeze({
|
|
undefined: Null,
|
|
boolean: Boolean,
|
|
number: Number,
|
|
bigint: BigInt,
|
|
string: String,
|
|
symbol: Symbol,
|
|
object: Object,
|
|
function: Function
|
|
});
|