@ezs/strings
v1.0.5
Published
Plugin d'instructions ezs pour traiter des chaînes de caractères
Downloads
68
Readme
@ezs/strings
Des intructions pour manipuler des chaînes de caratères.
installation
npm install @ezs/core
npm install @ezs/strings
À mettre au début du script:
[use]
plugin = strings
usage
Table of Contents
decode
Decodes a given string using a provided mapping, replacing strings that match values (to)in the mapping with their corresponding keys (from). Optionally, a prefix and suffix can be set (they are removed too from strings).
This statement is the reverse of encode
.
Input:
[{
"id": "1",
"value": "Flow control based inffivesup MW wind turbine",
}, {
"id": "2",
"value": "Motion Characteristics of infonesupinfzerosup MW Superconducting Floating Offshore Wind Turbine",
}]
Script:
[decode]
path = value
from = 1
to = one
from = 5
to = five
from = 0
to = zero
prefix = inf
suffix = sup
Output:
[{
"id": "1",
"value": "Flow control based 5 MW wind turbine",
}, {
"id": "2",
"value": "Motion Characteristics of 10 MW Superconducting Floating Offshore Wind Turbine",
}]
⚠ You must give as much
from
asto
.
See encode
.
Parameters
path
string The path of the string to be decoded, within data.from
Array<string> An array of strings to replace with.to
Array<string> An array of strings to be replaced.prefix
string A string to be removed from the beginning of each replaced substring. (optional, default""
)suffix
string A string to be removed from the end of each replaced substring. (optional, default""
)
encode
Encodes a given string using a provided mapping, replacing characters that match keys in the mapping with their corresponding values. Optionally, a prefix and suffix can be added to the final result.
Input:
[{
"id": "1",
"value": "Flow control based 5 MW wind turbine",
}, {
"id": "2",
"value": "Motion Characteristics of 10 MW Superconducting Floating Offshore Wind Turbine",
}]
Script:
[encode]
path = value
from = 1
to = one
from = 5
to = five
from = 0
to = zero
prefix = inf
suffix = sup
Output:
[{
"id": "1",
"value": "Flow control based inffivesup MW wind turbine",
}, {
"id": "2",
"value": "Motion Characteristics of infonesupinfzerosup MW Superconducting Floating Offshore Wind Turbine",
}]
⚠ The replacements are made in the order of the
from
array. This means that if 1 is replaced with 2, and next 2 replaced with 3, a 1 is eventually replaced with 3.
⚠ You must give as much
from
asto
.
See decode
to invert the processus.
Parameters
path
string The path of the string to be encoded, within data.from
Array<string> An array of strings to replace.to
Array<string> An array of strings to replace with.prefix
string A string to be added to the beginning of each replaced substring. (optional, default""
)suffix
string A string to be added to the end of each replaced substring. (optional, default""
)
inflection
Take a String
and inflect it with or more transformers from this list
pluralize, singularize, camelize, underscore, humanize, capitalize,
dasherize, titleize, demodulize, tableize, classify, foreign_key, ordinalize
Input:
{ "id": 1, "value": "all job" }
Script:
[inflection]
path = value
transform = pluralize
transform = capitalize
transform = dasherize
Output:
{ "id": 1, "value": "All-jobs" }
📗 When the path is not given, the input data is considered as a string, allowing to apply
inflection
on a string stream.
see https://www.npmjs.com/package/inflection
Parameters
path
string path of the field to segment (optional, default""
)transform
string? name of a transformer
sentences
Take a String
and split it into an array of sentences.
Input:
{ "id": 1, "value": "First sentence? Second sentence. My name is Bond, J. Bond." }
Output:
{ "id": 1, "value": ["First sentence?", "Second sentence.", "My name is Bond, J. Bond."] }
📗 When the path is not given, the input data is considered as a string, allowing to apply
inflection
on a string stream.
Parameters
path
string path of the field to segment (optional, default""
)