@mapcss/core
Version:
Tiny, composable Atomic CSS engine
75 lines (74 loc) • 2.98 kB
JavaScript
export { isEmptyObject, isFunction, isLength0, isNumber, isObject, isString, isSymbol, } from "./deps/deno.land/x/isx@v1.0.0-beta.17/mod.js";
import { isLength0, isNumber, isObject, isString, isUndefined, } from "./deps/deno.land/x/isx@v1.0.0-beta.17/mod.js";
export { deepMerge } from "./deps/deno.land/std@0.122.0/collections/deep_merge.js";
export { associateWith } from "./deps/deno.land/std@0.123.0/collections/associate_with.js";
export { mapEntries } from "./deps/deno.land/std@0.123.0/collections/map_entries.js";
export { filterValues } from "./deps/deno.land/std@0.123.0/collections/filter_values.js";
export { distinctBy } from "./deps/deno.land/std@0.125.0/collections/distinct_by.js";
export { union } from "./deps/deno.land/std@0.125.0/collections/union.js";
export { sortBy } from "./deps/deno.land/std@0.125.0/collections/sort_by.js";
export { curry } from "./deps/deno.land/x/curry@v1.0.0/mod.js";
export { None, Some, } from "./deps/deno.land/x/monads@v0.5.10/option/option.js";
export { Left, Right, } from "./deps/deno.land/x/monads@v0.5.10/either/either.js";
export { isUndefined };
import Rule from "./deps/deno.land/x/postcss@8.4.6/lib/rule.js";
import Declaration from "./deps/deno.land/x/postcss@8.4.6/lib/declaration.js";
import AtRule from "./deps/deno.land/x/postcss@8.4.6/lib/at-rule.js";
import Root from "./deps/deno.land/x/postcss@8.4.6/lib/root.js";
import postcss from "./deps/deno.land/x/postcss@8.4.6/lib/postcss.js";
export { AtRule, Declaration, postcss, Root, Rule };
export { toAST, toObject, } from "./deps/deno.land/x/postcss_js@v1.0.0-beta.2/mod.js";
export function isStringOrNumber(value) {
return isString(value) || isNumber(value);
}
export function isRegExp(value) {
return value instanceof RegExp;
}
/** check field is exist or not */
export function has(key, object) {
return Object.hasOwnProperty.call(object, key);
}
/** safe get accessor */
export function prop(key, object) {
return (object)[key];
}
/** take elements except head */
export function tail(val) {
return val.slice(1, Infinity);
}
/** safe get accessor deeply */
export function propPath(path, object) {
const key = path[0];
if (isUndefined(key))
return undefined;
const rest = tail(path);
if (isLength0(rest)) {
return prop(key, object);
}
const nested = prop(key, object);
if (has(key, object) && isObject(nested)) {
return propPath(rest, nested);
}
return undefined;
}
/** take last element of `array` */
export function last(value) {
return value.slice(-1)[0];
}
export function init(value) {
return value.slice(0, -1);
}
/** safe accessor for first element */
export function head(value) {
return value[0];
}
/** High precision round */
export function roundTo(num, digit) {
return +(Math.round(Number(num + `e+${digit}`)) + `e-${digit}`);
}
export function chain(val) {
return {
map: (fn) => chain(fn(val)),
unwrap: () => val,
};
}