New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@palett/fluo-entries

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@palett/fluo-entries - npm Package Compare versions

Comparing version 0.2.11 to 0.2.12

529

dist/index.cjs.js

@@ -52,475 +52,2 @@ 'use strict';

*
* @type {Function|function(*):string}
*/
const protoType = Function.prototype.call.bind(Object.prototype.toString);
const isNumeric = x => !isNaN(x - parseFloat(x));
const stringValue = word => {
let l = word === null || word === void 0 ? void 0 : word.length;
if (!l) return NaN;
if (l >= 4) return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14) + ((word.charCodeAt(2) & 0x7f) << 7) + (word.charCodeAt(3) & 0x7f);
if (l === 3) return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14) + ((word.charCodeAt(2) & 0x7f) << 7);
if (l === 2) return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14);
if (l === 1) return (word.charCodeAt(0) & 0x7f) << 21;
};
const LITERAL = /[A-Za-z0-9]+/;
const isLiteral = x => LITERAL.test(x);
const iterate = function (vec, fn, l) {
l = l || vec && vec.length;
for (let i = 0; i < l; i++) fn.call(this, vec[i], i);
};
const parseNumeric = x => +x;
const duobound = function (words, [x, y] = []) {
var _x$filter, _x$mapper, _y$filter, _y$mapper;
const l = words === null || words === void 0 ? void 0 : words.length;
let vX = undefined,
vY = undefined;
if (!l) return [vX, vY];
const filterX = (_x$filter = x === null || x === void 0 ? void 0 : x.filter) !== null && _x$filter !== void 0 ? _x$filter : isNumeric,
mapperX = (_x$mapper = x === null || x === void 0 ? void 0 : x.mapper) !== null && _x$mapper !== void 0 ? _x$mapper : parseNumeric;
const filterY = (_y$filter = y === null || y === void 0 ? void 0 : y.filter) !== null && _y$filter !== void 0 ? _y$filter : isLiteral,
mapperY = (_y$mapper = y === null || y === void 0 ? void 0 : y.mapper) !== null && _y$mapper !== void 0 ? _y$mapper : stringValue;
iterate(words, (v, i) => {
var _vX, _vY;
if (filterX(v) && ((_vX = vX) !== null && _vX !== void 0 ? _vX : vX = Array(l))) {
var _vX$max;
v = mapperX(v);
if (v > ((_vX$max = vX.max) !== null && _vX$max !== void 0 ? _vX$max : vX.max = vX.min = v)) {
vX.max = v;
} else if (v < vX.min) {
vX.min = v;
}
return vX[i] = v;
}
if (filterY(v) && ((_vY = vY) !== null && _vY !== void 0 ? _vY : vY = Array(l))) {
var _vY$max;
v = mapperY(v);
if (v > ((_vY$max = vY.max) !== null && _vY$max !== void 0 ? _vY$max : vY.max = vY.min = v)) {
vY.max = v;
} else if (v < vY.min) {
vY.min = v;
}
return vY[i] = v;
}
return NaN;
}, l);
return [vX, vY];
};
const max = (a, b) => a > b ? a : b;
const min = (a, b) => a < b ? a : b;
/**
*
* @param {number} x
* @returns {number}
*/
/**
*
* @param {number} x
* @returns {number}
*/
const round = x => x + (x > 0 ? 0.5 : -0.5) << 0;
const bound = ([r, g, b]) => {
let ma = r,
mi = r;
if (g > r) {
ma = g;
} else {
mi = g;
}
if (b > ma) ma = b;
if (b < mi) mi = b;
return {
max: ma,
sum: ma + mi,
dif: ma - mi
};
};
const hue = (r, g, b, max, dif) => {
if (dif === 0) return 0;
switch (max) {
case r:
return ((g - b) / dif + (g < b ? 6 : 0)) % 6;
case g:
return (b - r) / dif + 2;
case b:
return (r - g) / dif + 4;
}
};
const THOUSAND = 1000;
/**
* !dif: dif===0
* @param {number} r - [0,255]
* @param {number} g - [0,255]
* @param {number} b - [0,255]
* @returns {[number,number,number]} [Hue([0,360]), Saturation([0,100]), Lightness([0,100])]
*/
function rgbToHsl([r, g, b]) {
r /= 255;
g /= 255;
b /= 255;
const {
max,
sum,
dif
} = bound([r, g, b]);
let h = hue(r, g, b, max, dif) * 60,
s = !dif ? 0 : sum > 1 ? dif / (2 - sum) : dif / sum,
l = sum / 2;
return [round(h), round(s * THOUSAND) / 10, round(l * THOUSAND) / 10];
}
const diluteHex = (hex, hi) => {
hi = hi || hex.length;
let x = '';
for (let i = 0, el; i < hi; i++) {
el = hex[i];
x += el + el;
} // for (let c of hex) x += c + c
return x;
};
/**
*
* @param {string} hex
* @returns {number}
*/
function hexToInt(hex) {
if (hex.charAt(0) === '#') hex = hex.substring(1);
if (!hex[3]) hex = diluteHex(hex);
return parseInt(hex, 16);
}
/**
*
* @param {string} hex
* @returns {number[]}
*/
function hexToRgb(hex) {
const int = hexToInt(hex);
return [int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF];
}
const hexToHsl = hex => {
var _ref, _hex;
return _ref = (_hex = hex, hexToRgb(_hex)), rgbToHsl(_ref);
};
/**
*
* @param {number} n
* @param {number} h
* @param {number} a
* @param {number} l
* @returns {number}
*/
const hf = (n, h, a, l) => {
const k = (n + h / 30) % 12;
return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
};
/**
*
* @param {number} h
* @param {number} s
* @param {number} l
* @returns {number[]}
*/
function hslToRgb([h, s, l]) {
s /= 100;
l /= 100;
const a = s * Math.min(l, 1 - l),
r = hf(0, h, a, l),
g = hf(8, h, a, l),
b = hf(4, h, a, l);
return [round(r * 0xFF), round(g * 0xFF), round(b * 0xFF)]; // return [r * 0xFF & 0xFF, g * 0xFF & 0xFF, b * 0xFF & 0xFF]
}
const ESC = '\u001b';
const L = ESC + '[';
const R = 'm';
const SC = ';';
const FORE = '38;2';
const CLR_FORE = '39';
// black: 30,
// Red: 31,
// Green: 32,
// Yellow: 33,
// Blue: 34,
// magenta: 35,
// Cyan: 36,
// white: 37,
// Grey: 90,
// }
const BOLD = '1';
const ITALIC = '3';
const UNDERLINE = '4';
const INVERSE = '7';
const CLR_BOLD = '22';
const CLR_ITALIC = '23';
const CLR_UNDERLINE = '24';
const CLR_INVERSE = '27';
const Effects = {
bold: [BOLD, CLR_BOLD],
italic: [ITALIC, CLR_ITALIC],
underline: [UNDERLINE, CLR_UNDERLINE],
inverse: [INVERSE, CLR_INVERSE]
};
/**
*
* @param {string} code
* @returns {string}
*/
const brt = code => L + code + R;
/**
*
* @param {number[]} rgb - array of three integers, each from 0 to 255
* @returns {string}
*/
const rgbToAnsi = rgb => FORE + SC + rgb[0] + SC + rgb[1] + SC + rgb[2];
/**
*
* @param {string} tx
* @returns {string}
*/
function codedDyer(tx) {
const {
h,
t
} = this;
return brt(h) + tx + brt(t);
}
const parseEffects = effects => {
let h = '',
t = '';
if (effects.length) {
let l, r;
for (let e of effects) if (e in Effects && ([l, r] = Effects[e])) h += SC + l, t += SC + r;
}
return {
h,
t
};
};
/***
*
* @param {number[]} rgb
* @param {...string} [effects]
* @returns {function(string):string}
*/
const Dye = (rgb, ...effects) => {
const config = parseEffects(effects);
config.h += SC + rgbToAnsi(rgb), config.t += SC + CLR_FORE;
return codedDyer.bind(config);
};
/**
* Create a dye from a hsl array
* @param {[number,number,number]} hsl
* @returns {function}
*/
const hslToDye = hsl => {
var _ref, _hsl;
return _ref = (_hsl = hsl, hslToRgb(_hsl)), Dye(_ref);
};
const STR = 'string';
const parseHsl = color => {
var _color;
return typeof color === STR ? (_color = color, hexToHsl(_color)) : color;
};
/**
*
* @param max
* @param min
* @returns {{dif: [number,number,number], min: [number,number,number]}}
*/
const colorBound = ([maxH, maxS, maxL], [minH, minS, minL]) => ({
min: [minH, minS, minL],
dif: [maxH - minH, maxS - minS, maxL - minL]
});
const presetToLeap = ({
max,
min
}) => {
var _max, _min;
return colorBound((_max = max, parseHsl(_max)), (_min = min, parseHsl(_min)));
};
const presetToFlat = ({
na
}) => {
var _ref, _na;
return _ref = (_na = na, parseHsl(_na)), hslToDye(_ref);
};
const nullish = x => x === null || x === void 0;
/**
*
* @param {Object} bound
* @param {number} [bound.min] - if min: if dif, return {min,dif}; if max, return calculated {min,dif}
* @param {number} [bound.dif] - if dif: if max, return calculated {min,dif}; else return {min:0,dif}
* @param {number} [bound.max] - if max: return {min:0,dif:max}; else return {min:0,dif:0}
* @return {{dif: number, min: number}}
*/
const boundToLeap = bound => {
let {
min,
max,
dif
} = bound;
if (!nullish(min)) {
if (!nullish(dif)) return {
min,
dif
};
if (!nullish(max)) return {
min,
dif: max - min
};
}
if (!nullish(dif)) {
if (!nullish(max)) return {
min: max - dif,
dif
};
return {
min: 0,
dif
};
}
if (!nullish(max)) return {
min: 0,
dif: max
};
return {
min: 0,
dif: 0
};
};
/**
* Create a dye from a hsl array
* @param {[number,number,number]} hsl
* @returns {function}
*/
const hslToDye$1 = hsl => {
var _ref, _hsl;
return _ref = (_hsl = hsl, hslToRgb(_hsl)), Dye(_ref);
};
const leverage = ([h, s, l], base) => [h / base, s / base, l / base];
const scale = (x, min$1, lever, base, ceil) => min((max(x, min$1) - min$1) * lever + base, ceil);
const projector = function (x) {
var _ref;
const {
min: m,
lever: [rH, rS, rL],
base: [mH, mS, mL]
} = this;
return _ref = [scale(x, m, rH, mH, 360), scale(x, m, rS, mS, 100), scale(x, m, rL, mL, 100)], hslToDye$1(_ref);
};
/**
*
* @param {{[min]:number,[max]:number,[dif]:number}} bound
* @param {{max:*,min:*}} preset
* @returns {function(*):function}
* @constructor
*/
const Projector = (bound, preset) => {
var _bound, _preset;
if (!bound) return void 0;
bound = (_bound = bound, boundToLeap(_bound));
/** @type {{min:number[],dif:number[]}} */
const leap = (_preset = preset, presetToLeap(_preset));
if (!bound.dif) {
const dye = hslToDye$1(leap.min);
return () => dye;
}
return projector.bind({
min: bound.min,
lever: leverage(leap.dif, bound.dif),
base: leap.min
});
};
/**
*
* @typedef {Object} PalettProjectConfig

@@ -531,61 +58,17 @@ * @typedef {Function} PalettProjectConfig.filter

*
* @param vec
* @param {PalettProjectConfig[]} presets
*/
const fluoVec = function (vec, presets$1 = []) {
var _x$preset, _y$preset;
if (!(vec === null || vec === void 0 ? void 0 : vec.length)) return [];
const colorant = this === null || this === void 0 ? void 0 : this.colorant,
mutate = this === null || this === void 0 ? void 0 : this.mutate;
const [x, y] = presets$1;
const pX = (_x$preset = x === null || x === void 0 ? void 0 : x.preset) !== null && _x$preset !== void 0 ? _x$preset : presets.FRESH,
pY = (_y$preset = y === null || y === void 0 ? void 0 : y.preset) !== null && _y$preset !== void 0 ? _y$preset : presets.PLANET;
const [bX, bY] = duobound(vec, presets$1);
const dX = Projector(bX, pX),
dY = Projector(bY, pY);
const mapper = mutate ? vector.mutate : vector.mapper;
return colorant ? mapper(vec, Colorant(bX, dX, bY, dY, presetToFlat(pX))) : mapper(vec, Pigment(bX, dX, bY, dY, presetToFlat(pY)));
};
const Colorant = function (bX, dX, bY, dY, dye) {
return (_, i) => {
const x = bX && bX[i],
y = bY && bY[i];
return !nullish(x) ? dX(x) : !nullish(y) ? dY(y) : dye;
};
};
const Pigment = function (bX, dX, bY, dY, dye) {
return (n, i) => {
var _n, _n2, _n3;
const x = bX && bX[i],
y = bY && bY[i];
return !nullish(x) ? (_n = n, dX(x)(_n)) : !nullish(y) ? (_n2 = n, dY(y)(_n2)) : (_n3 = n, dye(_n3));
};
};
/**
*
* @typedef {Object} PalettProjectConfig
* @typedef {Function} PalettProjectConfig.filter
* @typedef {Function} PalettProjectConfig.mapper
* @typedef {Object} PalettProjectConfig.preset
*
* @param entries
* @param {PalettProjectConfig[]} [presets]
* @param {string[]} [effects]
*/
const fluoEnt = function (entries, presets) {
const fluoEnt = function (entries, presets, effects) {
const colorant = this === null || this === void 0 ? void 0 : this.colorant,
mutate = this === null || this === void 0 ? void 0 : this.mutate;
let [keys, items] = entriesUnwind.unwind(entries);
fluoVec.call({
const config = {
colorant,
mutate: true
}, keys, presets);
fluoVec.call({
colorant,
mutate: true
}, items, presets);
};
fluoVector.fluoVec.call(config, keys, presets, effects);
fluoVector.fluoVec.call(config, items, presets, effects);
const rendered = entriesInit.wind(keys, items);

@@ -592,0 +75,0 @@ return mutate ? entriesZipper.mutazip(entries, rendered, (a, b) => b) : rendered;

@@ -1,6 +0,6 @@

import { fluoVector } from '@palett/fluo-vector';
import { fluoVector, fluoVec } from '@palett/fluo-vector';
import { FRESH, PLANET } from '@palett/presets';
import { unwind } from '@vect/entries-unwind';
import { mutazip as mutazip$1 } from '@vect/entries-zipper';
import { mutazip, mutate, mapper } from '@vect/vector';
import { mutazip } from '@vect/vector';
import { wind } from '@vect/entries-init';

@@ -48,475 +48,2 @@

*
* @type {Function|function(*):string}
*/
const protoType = Function.prototype.call.bind(Object.prototype.toString);
const isNumeric = x => !isNaN(x - parseFloat(x));
const stringValue = word => {
let l = word === null || word === void 0 ? void 0 : word.length;
if (!l) return NaN;
if (l >= 4) return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14) + ((word.charCodeAt(2) & 0x7f) << 7) + (word.charCodeAt(3) & 0x7f);
if (l === 3) return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14) + ((word.charCodeAt(2) & 0x7f) << 7);
if (l === 2) return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14);
if (l === 1) return (word.charCodeAt(0) & 0x7f) << 21;
};
const LITERAL = /[A-Za-z0-9]+/;
const isLiteral = x => LITERAL.test(x);
const iterate = function (vec, fn, l) {
l = l || vec && vec.length;
for (let i = 0; i < l; i++) fn.call(this, vec[i], i);
};
const parseNumeric = x => +x;
const duobound = function (words, [x, y] = []) {
var _x$filter, _x$mapper, _y$filter, _y$mapper;
const l = words === null || words === void 0 ? void 0 : words.length;
let vX = undefined,
vY = undefined;
if (!l) return [vX, vY];
const filterX = (_x$filter = x === null || x === void 0 ? void 0 : x.filter) !== null && _x$filter !== void 0 ? _x$filter : isNumeric,
mapperX = (_x$mapper = x === null || x === void 0 ? void 0 : x.mapper) !== null && _x$mapper !== void 0 ? _x$mapper : parseNumeric;
const filterY = (_y$filter = y === null || y === void 0 ? void 0 : y.filter) !== null && _y$filter !== void 0 ? _y$filter : isLiteral,
mapperY = (_y$mapper = y === null || y === void 0 ? void 0 : y.mapper) !== null && _y$mapper !== void 0 ? _y$mapper : stringValue;
iterate(words, (v, i) => {
var _vX, _vY;
if (filterX(v) && ((_vX = vX) !== null && _vX !== void 0 ? _vX : vX = Array(l))) {
var _vX$max;
v = mapperX(v);
if (v > ((_vX$max = vX.max) !== null && _vX$max !== void 0 ? _vX$max : vX.max = vX.min = v)) {
vX.max = v;
} else if (v < vX.min) {
vX.min = v;
}
return vX[i] = v;
}
if (filterY(v) && ((_vY = vY) !== null && _vY !== void 0 ? _vY : vY = Array(l))) {
var _vY$max;
v = mapperY(v);
if (v > ((_vY$max = vY.max) !== null && _vY$max !== void 0 ? _vY$max : vY.max = vY.min = v)) {
vY.max = v;
} else if (v < vY.min) {
vY.min = v;
}
return vY[i] = v;
}
return NaN;
}, l);
return [vX, vY];
};
const max = (a, b) => a > b ? a : b;
const min = (a, b) => a < b ? a : b;
/**
*
* @param {number} x
* @returns {number}
*/
/**
*
* @param {number} x
* @returns {number}
*/
const round = x => x + (x > 0 ? 0.5 : -0.5) << 0;
const bound = ([r, g, b]) => {
let ma = r,
mi = r;
if (g > r) {
ma = g;
} else {
mi = g;
}
if (b > ma) ma = b;
if (b < mi) mi = b;
return {
max: ma,
sum: ma + mi,
dif: ma - mi
};
};
const hue = (r, g, b, max, dif) => {
if (dif === 0) return 0;
switch (max) {
case r:
return ((g - b) / dif + (g < b ? 6 : 0)) % 6;
case g:
return (b - r) / dif + 2;
case b:
return (r - g) / dif + 4;
}
};
const THOUSAND = 1000;
/**
* !dif: dif===0
* @param {number} r - [0,255]
* @param {number} g - [0,255]
* @param {number} b - [0,255]
* @returns {[number,number,number]} [Hue([0,360]), Saturation([0,100]), Lightness([0,100])]
*/
function rgbToHsl([r, g, b]) {
r /= 255;
g /= 255;
b /= 255;
const {
max,
sum,
dif
} = bound([r, g, b]);
let h = hue(r, g, b, max, dif) * 60,
s = !dif ? 0 : sum > 1 ? dif / (2 - sum) : dif / sum,
l = sum / 2;
return [round(h), round(s * THOUSAND) / 10, round(l * THOUSAND) / 10];
}
const diluteHex = (hex, hi) => {
hi = hi || hex.length;
let x = '';
for (let i = 0, el; i < hi; i++) {
el = hex[i];
x += el + el;
} // for (let c of hex) x += c + c
return x;
};
/**
*
* @param {string} hex
* @returns {number}
*/
function hexToInt(hex) {
if (hex.charAt(0) === '#') hex = hex.substring(1);
if (!hex[3]) hex = diluteHex(hex);
return parseInt(hex, 16);
}
/**
*
* @param {string} hex
* @returns {number[]}
*/
function hexToRgb(hex) {
const int = hexToInt(hex);
return [int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF];
}
const hexToHsl = hex => {
var _ref, _hex;
return _ref = (_hex = hex, hexToRgb(_hex)), rgbToHsl(_ref);
};
/**
*
* @param {number} n
* @param {number} h
* @param {number} a
* @param {number} l
* @returns {number}
*/
const hf = (n, h, a, l) => {
const k = (n + h / 30) % 12;
return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
};
/**
*
* @param {number} h
* @param {number} s
* @param {number} l
* @returns {number[]}
*/
function hslToRgb([h, s, l]) {
s /= 100;
l /= 100;
const a = s * Math.min(l, 1 - l),
r = hf(0, h, a, l),
g = hf(8, h, a, l),
b = hf(4, h, a, l);
return [round(r * 0xFF), round(g * 0xFF), round(b * 0xFF)]; // return [r * 0xFF & 0xFF, g * 0xFF & 0xFF, b * 0xFF & 0xFF]
}
const ESC = '\u001b';
const L = ESC + '[';
const R = 'm';
const SC = ';';
const FORE = '38;2';
const CLR_FORE = '39';
// black: 30,
// Red: 31,
// Green: 32,
// Yellow: 33,
// Blue: 34,
// magenta: 35,
// Cyan: 36,
// white: 37,
// Grey: 90,
// }
const BOLD = '1';
const ITALIC = '3';
const UNDERLINE = '4';
const INVERSE = '7';
const CLR_BOLD = '22';
const CLR_ITALIC = '23';
const CLR_UNDERLINE = '24';
const CLR_INVERSE = '27';
const Effects = {
bold: [BOLD, CLR_BOLD],
italic: [ITALIC, CLR_ITALIC],
underline: [UNDERLINE, CLR_UNDERLINE],
inverse: [INVERSE, CLR_INVERSE]
};
/**
*
* @param {string} code
* @returns {string}
*/
const brt = code => L + code + R;
/**
*
* @param {number[]} rgb - array of three integers, each from 0 to 255
* @returns {string}
*/
const rgbToAnsi = rgb => FORE + SC + rgb[0] + SC + rgb[1] + SC + rgb[2];
/**
*
* @param {string} tx
* @returns {string}
*/
function codedDyer(tx) {
const {
h,
t
} = this;
return brt(h) + tx + brt(t);
}
const parseEffects = effects => {
let h = '',
t = '';
if (effects.length) {
let l, r;
for (let e of effects) if (e in Effects && ([l, r] = Effects[e])) h += SC + l, t += SC + r;
}
return {
h,
t
};
};
/***
*
* @param {number[]} rgb
* @param {...string} [effects]
* @returns {function(string):string}
*/
const Dye = (rgb, ...effects) => {
const config = parseEffects(effects);
config.h += SC + rgbToAnsi(rgb), config.t += SC + CLR_FORE;
return codedDyer.bind(config);
};
/**
* Create a dye from a hsl array
* @param {[number,number,number]} hsl
* @returns {function}
*/
const hslToDye = hsl => {
var _ref, _hsl;
return _ref = (_hsl = hsl, hslToRgb(_hsl)), Dye(_ref);
};
const STR = 'string';
const parseHsl = color => {
var _color;
return typeof color === STR ? (_color = color, hexToHsl(_color)) : color;
};
/**
*
* @param max
* @param min
* @returns {{dif: [number,number,number], min: [number,number,number]}}
*/
const colorBound = ([maxH, maxS, maxL], [minH, minS, minL]) => ({
min: [minH, minS, minL],
dif: [maxH - minH, maxS - minS, maxL - minL]
});
const presetToLeap = ({
max,
min
}) => {
var _max, _min;
return colorBound((_max = max, parseHsl(_max)), (_min = min, parseHsl(_min)));
};
const presetToFlat = ({
na
}) => {
var _ref, _na;
return _ref = (_na = na, parseHsl(_na)), hslToDye(_ref);
};
const nullish = x => x === null || x === void 0;
/**
*
* @param {Object} bound
* @param {number} [bound.min] - if min: if dif, return {min,dif}; if max, return calculated {min,dif}
* @param {number} [bound.dif] - if dif: if max, return calculated {min,dif}; else return {min:0,dif}
* @param {number} [bound.max] - if max: return {min:0,dif:max}; else return {min:0,dif:0}
* @return {{dif: number, min: number}}
*/
const boundToLeap = bound => {
let {
min,
max,
dif
} = bound;
if (!nullish(min)) {
if (!nullish(dif)) return {
min,
dif
};
if (!nullish(max)) return {
min,
dif: max - min
};
}
if (!nullish(dif)) {
if (!nullish(max)) return {
min: max - dif,
dif
};
return {
min: 0,
dif
};
}
if (!nullish(max)) return {
min: 0,
dif: max
};
return {
min: 0,
dif: 0
};
};
/**
* Create a dye from a hsl array
* @param {[number,number,number]} hsl
* @returns {function}
*/
const hslToDye$1 = hsl => {
var _ref, _hsl;
return _ref = (_hsl = hsl, hslToRgb(_hsl)), Dye(_ref);
};
const leverage = ([h, s, l], base) => [h / base, s / base, l / base];
const scale = (x, min$1, lever, base, ceil) => min((max(x, min$1) - min$1) * lever + base, ceil);
const projector = function (x) {
var _ref;
const {
min: m,
lever: [rH, rS, rL],
base: [mH, mS, mL]
} = this;
return _ref = [scale(x, m, rH, mH, 360), scale(x, m, rS, mS, 100), scale(x, m, rL, mL, 100)], hslToDye$1(_ref);
};
/**
*
* @param {{[min]:number,[max]:number,[dif]:number}} bound
* @param {{max:*,min:*}} preset
* @returns {function(*):function}
* @constructor
*/
const Projector = (bound, preset) => {
var _bound, _preset;
if (!bound) return void 0;
bound = (_bound = bound, boundToLeap(_bound));
/** @type {{min:number[],dif:number[]}} */
const leap = (_preset = preset, presetToLeap(_preset));
if (!bound.dif) {
const dye = hslToDye$1(leap.min);
return () => dye;
}
return projector.bind({
min: bound.min,
lever: leverage(leap.dif, bound.dif),
base: leap.min
});
};
/**
*
* @typedef {Object} PalettProjectConfig

@@ -527,61 +54,17 @@ * @typedef {Function} PalettProjectConfig.filter

*
* @param vec
* @param {PalettProjectConfig[]} presets
*/
const fluoVec = function (vec, presets = []) {
var _x$preset, _y$preset;
if (!(vec === null || vec === void 0 ? void 0 : vec.length)) return [];
const colorant = this === null || this === void 0 ? void 0 : this.colorant,
mutate$1 = this === null || this === void 0 ? void 0 : this.mutate;
const [x, y] = presets;
const pX = (_x$preset = x === null || x === void 0 ? void 0 : x.preset) !== null && _x$preset !== void 0 ? _x$preset : FRESH,
pY = (_y$preset = y === null || y === void 0 ? void 0 : y.preset) !== null && _y$preset !== void 0 ? _y$preset : PLANET;
const [bX, bY] = duobound(vec, presets);
const dX = Projector(bX, pX),
dY = Projector(bY, pY);
const mapper$1 = mutate$1 ? mutate : mapper;
return colorant ? mapper$1(vec, Colorant(bX, dX, bY, dY, presetToFlat(pX))) : mapper$1(vec, Pigment(bX, dX, bY, dY, presetToFlat(pY)));
};
const Colorant = function (bX, dX, bY, dY, dye) {
return (_, i) => {
const x = bX && bX[i],
y = bY && bY[i];
return !nullish(x) ? dX(x) : !nullish(y) ? dY(y) : dye;
};
};
const Pigment = function (bX, dX, bY, dY, dye) {
return (n, i) => {
var _n, _n2, _n3;
const x = bX && bX[i],
y = bY && bY[i];
return !nullish(x) ? (_n = n, dX(x)(_n)) : !nullish(y) ? (_n2 = n, dY(y)(_n2)) : (_n3 = n, dye(_n3));
};
};
/**
*
* @typedef {Object} PalettProjectConfig
* @typedef {Function} PalettProjectConfig.filter
* @typedef {Function} PalettProjectConfig.mapper
* @typedef {Object} PalettProjectConfig.preset
*
* @param entries
* @param {PalettProjectConfig[]} [presets]
* @param {string[]} [effects]
*/
const fluoEnt = function (entries, presets) {
const fluoEnt = function (entries, presets, effects) {
const colorant = this === null || this === void 0 ? void 0 : this.colorant,
mutate = this === null || this === void 0 ? void 0 : this.mutate;
let [keys, items] = unwind(entries);
fluoVec.call({
const config = {
colorant,
mutate: true
}, keys, presets);
fluoVec.call({
colorant,
mutate: true
}, items, presets);
};
fluoVec.call(config, keys, presets, effects);
fluoVec.call(config, items, presets, effects);
const rendered = wind(keys, items);

@@ -588,0 +71,0 @@ return mutate ? mutazip$1(entries, rendered, (a, b) => b) : rendered;

8

package.json
{
"name": "@palett/fluo-entries",
"version": "0.2.11",
"version": "0.2.12",
"description": "A colorant to string",

@@ -18,4 +18,4 @@ "main": "dist/index.cjs.js",

"dependencies": {
"@palett/fluo-vector": "^0.2.11",
"@palett/presets": "^0.2.11",
"@palett/fluo-vector": "^0.2.12",
"@palett/presets": "^0.2.12",
"@vect/entries-init": "^0.2.4",

@@ -44,3 +44,3 @@ "@vect/entries-unwind": "^0.2.4",

"homepage": "https://github.com/hoyeungw/palett/fluo-entries#readme",
"gitHead": "bc5829f824fe916225e028f985a3a7ed9d364ff2"
"gitHead": "40671704dd995d641148d4ce9e9ae2de0f93e013"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc