@spare/deco-string
Advanced tools
Comparing version
import { SUBTLE } from '@palett/presets'; | ||
import { Node } from '@spare/node'; | ||
import { Node, parsePresm } from '@spare/node'; | ||
@@ -21,37 +21,20 @@ const { string } = Node.prototype; | ||
/** | ||
* | ||
* @param {Opt} conf | ||
* @returns {function} | ||
* @param {Opt} conf | ||
* @returns {(str:string,thr:[number],ind:[number],sur:[number])=>string} | ||
*/ | ||
function DecoString(conf) { | ||
conf = conf ?? this ?? {}; | ||
conf.pres = conf.pres ?? SUBTLE; | ||
conf.thres = conf.thres ?? 0; | ||
return string.bind(new Node(conf), conf.thres) | ||
conf.pres = parsePresm(conf?.pres ?? conf, SUBTLE); | ||
const thres = conf.thres ?? 0, indent = conf.indent, surge = conf.surge; | ||
const proc = string.bind(new Node(conf)); | ||
return (str, thr, ind, sur) => proc(str, thr ?? thres, ind ?? indent, sur ?? surge) | ||
} | ||
/** | ||
* | ||
* @param {string} str | ||
* @param {Opt} [conf] | ||
* @returns {string} | ||
*/ | ||
function decoString(str, conf) { | ||
conf = conf ?? this ?? {}; | ||
conf.pres = conf.pres ?? SUBTLE; | ||
conf.thres = conf.thres ?? 0; | ||
return string.call(new Node(conf), str, conf.thres, conf.indent, conf.surge) | ||
function decoString(str, thr, ind, sur) { | ||
const conf = this ?? {}; | ||
conf.pres = parsePresm(conf?.pres ?? conf, SUBTLE); | ||
const thres = conf.thres ?? 0, indent = conf.indent, surge = conf.surge; | ||
return string.call(new Node(conf), str, thr ?? thres, ind ?? indent, sur ?? surge) | ||
} | ||
// {string} text | ||
// {Object} [conf] | ||
// {number} [conf.width=80] | ||
// {number} [conf.indent] | ||
// {number} [conf.firstLineIndent] | ||
// {Object[]} [conf.presets] | ||
// {string[]} [conf.effects] | ||
// {Function} [conf.vectify] | ||
// {Function} [conf.joiner] | ||
export { DecoString, decoString }; |
{ | ||
"name": "@spare/deco-string", | ||
"version": "0.16.10", | ||
"version": "0.16.11", | ||
"description": "Color a string", | ||
@@ -17,5 +17,5 @@ "type": "module", | ||
"dependencies": { | ||
"@palett/enum-colorant-modes": "^0.12.11", | ||
"@palett/fluo-vector": "^0.12.11", | ||
"@palett/presets": "^0.12.11", | ||
"@palett/enum-colorant-modes": "^0.12.16", | ||
"@palett/fluo-vector": "^0.12.16", | ||
"@palett/presets": "^0.12.16", | ||
"@texting/charset-ansi": "^0.2.2", | ||
@@ -25,7 +25,7 @@ "@texting/enum-chars": "^0.2.2", | ||
"@texting/splitter": "^0.2.2", | ||
"@spare/node": "^0.16.10" | ||
"@spare/node": "^0.16.11" | ||
}, | ||
"devDependencies": { | ||
"@aryth/rand": "^0.7.3", | ||
"@aryth/rank-vector": "^0.7.3", | ||
"@aryth/rand": "^0.7.4", | ||
"@aryth/rank-vector": "^0.7.4", | ||
"@foba/object-string": "^0.6.1", | ||
@@ -39,6 +39,6 @@ "@foba/quotes-creativity": "^0.6.1", | ||
"@vect/object-mapper": "^0.8.0", | ||
"@spare/deco": "^0.16.10", | ||
"@spare/xr": "^0.16.10", | ||
"@spare/node": "^0.16.10", | ||
"@spare/logger": "^0.16.10" | ||
"@spare/logger": "^0.16.11", | ||
"@spare/node": "^0.16.11", | ||
"@spare/deco": "^0.16.11", | ||
"@spare/xr": "^0.16.11" | ||
}, | ||
@@ -45,0 +45,0 @@ "repository": { |
5539
-1.16%34
-30.61%Updated
Updated
Updated