- Source:
Methods
(private, inner) decodeUuid(value, baseopt) → {String|Void}
- Source:
- See:
Example
Example usage within a JSONata transform
// returns
// result = '1b49aa30-e719-11e6-9835-f723b46a2688'
const jsonata = require('jsonata-extended');
const expr = jsonata('$decodeUuid("1m5otdkthiyq143crwujacdqg", "base36")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1b49aa30-e719-11e6-9835-f723b46a2688'
const jsonata = require('jsonata-extended');
const expr = jsonata('$decodeUuid("1m5otdkthiyq143crwujacdqg", "base36")');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
String | Shortened UUID | ||
base |
'base2' | 'base10' | 'base16' | 'base32' | 'base36' | 'base58' | 'base62' | 'base64' | 'base64url' |
<optional> |
'base36'
|
A valid base to use for the process, case sensitive Encoding Options |
Throws:
-
Will throw an error if the value is not a valid uuid
-
Will throw an error if the base is not a valid option
Returns:
- Type
- String | Void
(private, inner) encodeUuid(value, baseopt) → {String|Void}
- Source:
- See:
Example
Example usage within a JSONata transform
// returns
// result = '1m5otdkthiyq143crwujacdqg'
const jsonata = require('jsonata-extended');
const expr = jsonata('$encodeUuid("1b49aa30-e719-11e6-9835-f723b46a2688", "base36")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1m5otdkthiyq143crwujacdqg'
const jsonata = require('jsonata-extended');
const expr = jsonata('$encodeUuid("1b49aa30-e719-11e6-9835-f723b46a2688", "base36")');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
String | Properly formatted UUID | ||
base |
'base2' | 'base10' | 'base16' | 'base32' | 'base36' | 'base58' | 'base62' | 'base64' | 'base64url' |
<optional> |
'base36'
|
A valid base to use for the process, case sensitive Encoding Options |
Throws:
-
Will throw an error if the value is not a valid uuid
-
Will throw an error if the base is not a valid option
Returns:
- Type
- String | Void
(private, inner) htmltotext(value, optionsopt) → {String|Void}
- Source:
- See:
Example
Example usage within a JSONata transform. The <p> tags and the HTML entities are converted
// returns
// result = 'Leadership has a dark side; a "leadership shadow" that often creates an unknown; lurking fear.'
const jsonata = require('jsonata-extended');
const expr = jsonata('$htmltotext("<p>Leadership has a dark side; a "leadership shadow" that often creates an unknown; lurking fear.</p>")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = 'Leadership has a dark side; a "leadership shadow" that often creates an unknown; lurking fear.'
const jsonata = require('jsonata-extended');
const expr = jsonata('$htmltotext("<p>Leadership has a dark side; a "leadership shadow" that often creates an unknown; lurking fear.</p>")');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String | The HTML string to convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
{}
|
The options object. For more information see the html-to-text NPM
Properties
|
Returns:
- Type
- String | Void
(private, inner) languageInfo(value) → {Array.<Object>|Void}
- Source:
- See:
Examples
ample usage within a JSONata transform to get detailed info with single tag with language only no locale
// returns
// result = {
// "rfc5646": "es",
// "region": null,
// "language": {
// "name": "Spanish",
// "native": "Español"
// }
// }
// }
const jsonata = require('jsonata-extended');
const expr = jsonata('$languageInfo("es")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = {
// "rfc5646": "es",
// "region": null,
// "language": {
// "name": "Spanish",
// "native": "Español"
// }
// }
// }
const jsonata = require('jsonata-extended');
const expr = jsonata('$languageInfo("es")');
const result = expr.evaluate();
Example usage within a JSONata transform to get the region native language name for a locale
// returns
// result = "中文"
const jsonata = require('jsonata-extended');
const expr = jsonata('$languageInfo("zh-CN").language.native');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = "中文"
const jsonata = require('jsonata-extended');
const expr = jsonata('$languageInfo("zh-CN").language.native');
const result = expr.evaluate();
Example usage within a JSONata transform to get the information for three locales
// returns
// result = [
// {
// "region": {
// "name": "United States",
// "native": "United States",
// "phone": "1",
// "continent": "NA",
// "capital": "Washington D.C.",
// "currency": "USD,USN,USS",
// "languages": [
// "en"
// ],
// "emoji": "🇺🇸",
// "emojiU": "U+1F1FA U+1F1F8"
// },
// "language": {
// "name": "English",
// "native": "English"
// },
// "rfc5646": "en-US"
// },
// {
// "region": {
// "name": "France",
// "native": "France",
// "phone": "33",
// "continent": "EU",
// "capital": "Paris",
// "currency": "EUR",
// "languages": [
// "fr"
// ],
// "emoji": "🇫🇷",
// "emojiU": "U+1F1EB U+1F1F7"
// },
// "language": {
// "name": "French",
// "native": "Français"
// },
// "rfc5646": "fr-FR"
// },
// {
// "region": {
// "name": "China",
// "native": "中国",
// "phone": "86",
// "continent": "AS",
// "capital": "Beijing",
// "currency": "CNY",
// "languages": [
// "zh"
// ],
// "emoji": "🇨🇳",
// "emojiU": "U+1F1E8 U+1F1F3"
// },
// "language": {
// "name": "Chinese",
// "native": "中文"
// },
// "rfc5646": "zh-CN"
// }
// ]
const jsonata = require('jsonata-extended');
const expr = jsonata('( $allLocales:= ["en-US", "fr-FR", "zh-CN"]; $map($allLocales, function($v, $i, $a) { $languageInfo($v) }) )');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = [
// {
// "region": {
// "name": "United States",
// "native": "United States",
// "phone": "1",
// "continent": "NA",
// "capital": "Washington D.C.",
// "currency": "USD,USN,USS",
// "languages": [
// "en"
// ],
// "emoji": "🇺🇸",
// "emojiU": "U+1F1FA U+1F1F8"
// },
// "language": {
// "name": "English",
// "native": "English"
// },
// "rfc5646": "en-US"
// },
// {
// "region": {
// "name": "France",
// "native": "France",
// "phone": "33",
// "continent": "EU",
// "capital": "Paris",
// "currency": "EUR",
// "languages": [
// "fr"
// ],
// "emoji": "🇫🇷",
// "emojiU": "U+1F1EB U+1F1F7"
// },
// "language": {
// "name": "French",
// "native": "Français"
// },
// "rfc5646": "fr-FR"
// },
// {
// "region": {
// "name": "China",
// "native": "中国",
// "phone": "86",
// "continent": "AS",
// "capital": "Beijing",
// "currency": "CNY",
// "languages": [
// "zh"
// ],
// "emoji": "🇨🇳",
// "emojiU": "U+1F1E8 U+1F1F3"
// },
// "language": {
// "name": "Chinese",
// "native": "中文"
// },
// "rfc5646": "zh-CN"
// }
// ]
const jsonata = require('jsonata-extended');
const expr = jsonata('( $allLocales:= ["en-US", "fr-FR", "zh-CN"]; $map($allLocales, function($v, $i, $a) { $languageInfo($v) }) )');
const result = expr.evaluate();
Example usage within a JSONata transform to get a new object with the RFC5646 tag, and a string 'region (language)' representing the native locale for three locales
// returns
// result = [
// {
// "rfc5646": "en-US",
// "locale": "United States (English)"
// },
// {
// "rfc5646": "fr-FR",
// "locale": "France (Français)"
// },
// {
// "rfc5646": "zh-CN",
// "locale": "中国 (中文)"
// }
// ]
const jsonata = require('jsonata-extended');
const expr = jsonata('( $allLocales:= ["en-US", "fr-FR", "zh-CN"]; $map($allLocales, function($v, $i, $a) { ( $lang := $languageInfo($v); { "rfc5646": $lang.rfc5646, "locale" : $lang.region.native & " (" & $lang.language.native &")" })}) )');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = [
// {
// "rfc5646": "en-US",
// "locale": "United States (English)"
// },
// {
// "rfc5646": "fr-FR",
// "locale": "France (Français)"
// },
// {
// "rfc5646": "zh-CN",
// "locale": "中国 (中文)"
// }
// ]
const jsonata = require('jsonata-extended');
const expr = jsonata('( $allLocales:= ["en-US", "fr-FR", "zh-CN"]; $map($allLocales, function($v, $i, $a) { ( $lang := $languageInfo($v); { "rfc5646": $lang.rfc5646, "locale" : $lang.region.native & " (" & $lang.language.native &")" })}) )');
const result = expr.evaluate();
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | The RFC5646 locales to retrieve detailed information on |
Throws:
Returns:
- Type
- Array.<Object> | Void
(private, inner) moment(…args) → {Object}
- Source:
- See:
Examples
Example usage within a JSONata transform to get the year of a ISO8601 string
// returns
// result = "2017"
const jsonata = require('jsonata-extended');
const expr = jsonata('$moment("2017-02-02T15:49:06Z").year()');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = "2017"
const jsonata = require('jsonata-extended');
const expr = jsonata('$moment("2017-02-02T15:49:06Z").year()');
const result = expr.evaluate();
Example usage within a JSONata transform to get the localised Italian month name for a date
// returns
// result = "dicembre"
const jsonata = require('jsonata-extended');
const expr = jsonata('( $momentit := $moment().locale(\"it\"); $momentit.localeData().months($moment(\"12-12-1995\",\"MM-DD-YYYY\")) )');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = "dicembre"
const jsonata = require('jsonata-extended');
const expr = jsonata('( $momentit := $moment().locale(\"it\"); $momentit.localeData().months($moment(\"12-12-1995\",\"MM-DD-YYYY\")) )');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
* |
<repeatable> |
The moment parse argument options |
Returns:
- Type
- Object
(private, inner) momentDuration(…args) → {Object}
- Source:
- See:
Examples
Example usage within a JSONata transform to get the total seconds of an ISO8601 duration string
// returns
// result = 3730
const jsonata = require('jsonata-extended');
const expr = jsonata('$momentDuration(\"PT1H2M10S\").asSeconds()');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = 3730
const jsonata = require('jsonata-extended');
const expr = jsonata('$momentDuration(\"PT1H2M10S\").asSeconds()');
const result = expr.evaluate();
Example usage within a JSONata transform to convert ISO8601 duration string to hh:mm:ss
// returns
// result = "74:02:10"
const jsonata = require('jsonata-extended');
const expr = jsonata('( $duration := $momentDuration(\"P3DT2H2M10S\"); $formatNumber($floor($duration.asHours()),\"#00\") & \":\" & $formatNumber($floor($duration.minutes()),\"00\") & \":\" & $formatNumber($floor($duration.seconds()),\"00\") )');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = "74:02:10"
const jsonata = require('jsonata-extended');
const expr = jsonata('( $duration := $momentDuration(\"P3DT2H2M10S\"); $formatNumber($floor($duration.asHours()),\"#00\") & \":\" & $formatNumber($floor($duration.minutes()),\"00\") & \":\" & $formatNumber($floor($duration.seconds()),\"00\") )');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
* |
<repeatable> |
The moment.duration argument options |
Returns:
- Type
- Object
(private, inner) mustache(value=opt, template=opt) → {String|Void}
- Source:
- See:
Examples
Example usage within a JSONata transform for converting object
// returns
// result = 'Martin Holden is a Learner'
const jsonata = require('jsonata-extended');
const expr = jsonata('$mustache( { "name" : "Martin Holden" , "role" : "Learner"}, \"{{name}} is a {{role}}\")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = 'Martin Holden is a Learner'
const jsonata = require('jsonata-extended');
const expr = jsonata('$mustache( { "name" : "Martin Holden" , "role" : "Learner"}, \"{{name}} is a {{role}}\")');
const result = expr.evaluate();
Example usage within a JSONata transform for converting more complex object
// returns
// result = '<h1>Nincompoopery: Why Your Customers Hate You--And How to Fix It</h1><h2>Authors:</h2><ul><li>John R. Brandt</li></ul><p>HarperCollins Leadership©2019</p>'
const jsonata = require('jsonata-extended');
const expr = jsonata('$mustache({ "title" : "Nincompoopery: Why Your Customers Hate You--And How to Fix It", "publication" : { "copyrightYear": 2019, "isbn": "9781400213672", "publisher": "HarperCollins Leadership" } , "authors" : ["John R. Brandt"]}, "<h1>{{title}}</h1>{{#authors.length}}<h2>Authors:</h2><ul>{{#authors}}<li>{{.}}</li>{{/authors}}</ul>{{/authors.length}}{{#publication}}<p>{{publisher}}©{{copyrightYear}}</p>{{/publication}}")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '<h1>Nincompoopery: Why Your Customers Hate You--And How to Fix It</h1><h2>Authors:</h2><ul><li>John R. Brandt</li></ul><p>HarperCollins Leadership©2019</p>'
const jsonata = require('jsonata-extended');
const expr = jsonata('$mustache({ "title" : "Nincompoopery: Why Your Customers Hate You--And How to Fix It", "publication" : { "copyrightYear": 2019, "isbn": "9781400213672", "publisher": "HarperCollins Leadership" } , "authors" : ["John R. Brandt"]}, "<h1>{{title}}</h1>{{#authors.length}}<h2>Authors:</h2><ul>{{#authors}}<li>{{.}}</li>{{/authors}}</ul>{{/authors.length}}{{#publication}}<p>{{publisher}}©{{copyrightYear}}</p>{{/publication}}")');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
value= |
Object |
<optional> |
The object to use with the template |
template= |
String |
<optional> |
The template object. For more information see the mustache NPM |
Returns:
- Type
- String | Void
(private, inner) parsePath(value) → {Object|Void}
- Source:
- See:
Examples
Example usage within a JSONata transform
// returns
// result = {
// "base": "page.html",
// "dir": "/p/a/t",
// "ext": ".html",
// "name": "page",
// "root": "/"
// }
const jsonata = require('jsonata-extended');
const expr = jsonata('$parsePath("/p/a/t/page.html")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = {
// "base": "page.html",
// "dir": "/p/a/t",
// "ext": ".html",
// "name": "page",
// "root": "/"
// }
const jsonata = require('jsonata-extended');
const expr = jsonata('$parsePath("/p/a/t/page.html")');
const result = expr.evaluate();
Example usage within a JSONata transform to get the file extension
// returns
// result = ".html"
const jsonata = require('jsonata-extended');
const expr = jsonata('$parsePath("/p/a/t/page.html").ext');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = ".html"
const jsonata = require('jsonata-extended');
const expr = jsonata('$parsePath("/p/a/t/page.html").ext');
const result = expr.evaluate();
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | Properly formatted path |
Throws:
Returns:
- Type
- Object | Void
(private, inner) parseUrl(value) → {Object|Void}
- Source:
- See:
Examples
Example usage within a JSONata transform
// returns
// result = {
// "slashes": true,
// "protocol": "http:",
// "hash": "#hash",
// "query": {
// "param1": "string",
// "param2": "true"
// },
// "pathname": "/p/a/t/page.html",
// "auth": "user:pass",
// "host": "host.com:8080",
// "port": "8080",
// "hostname": "host.com",
// "password": "pass",
// "username": "user",
// "origin": "http://host.com:8080",
// "href": "http://user:pass@host.com:8080/p/a/t/page.html?param1=string¶m2=true#hash"
// }
const jsonata = require('jsonata-extended');
const expr = jsonata('$parseUrl("http://user:pass@host.com:8080/p/a/t/page.html?param1=string¶m2=true#hash")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = {
// "slashes": true,
// "protocol": "http:",
// "hash": "#hash",
// "query": {
// "param1": "string",
// "param2": "true"
// },
// "pathname": "/p/a/t/page.html",
// "auth": "user:pass",
// "host": "host.com:8080",
// "port": "8080",
// "hostname": "host.com",
// "password": "pass",
// "username": "user",
// "origin": "http://host.com:8080",
// "href": "http://user:pass@host.com:8080/p/a/t/page.html?param1=string¶m2=true#hash"
// }
const jsonata = require('jsonata-extended');
const expr = jsonata('$parseUrl("http://user:pass@host.com:8080/p/a/t/page.html?param1=string¶m2=true#hash")');
const result = expr.evaluate();
Example usage within a JSONata transform to get the hostname
// returns
// result = "host.com"
const jsonata = require('jsonata-extended');
const expr = jsonata('$parseUrl("http://user:pass@host.com:8080/p/a/t/page.html?param1=string¶m2=true#hash").hostname');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = "host.com"
const jsonata = require('jsonata-extended');
const expr = jsonata('$parseUrl("http://user:pass@host.com:8080/p/a/t/page.html?param1=string¶m2=true#hash").hostname');
const result = expr.evaluate();
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | Properly formatted URL |
Throws:
Returns:
- Type
- Object | Void
(private, inner) registerWithJSONATA(expression)
- Source:
- See:
Example
Example usage to add the functions in this library to a JSONata expression object, and utilise them
const jsonata = require('jsonata');
const jsonataFunctions = require('jsonata-functions');
const expression = jsonata('$htmltotext("<p>Leadership has a dark side; a "leadership shadow" that often creates an unknown; lurking fear.</p>")');
jsonataFunctions.registerWithJSONATA(expression);
const result = expression.evaluate();
Try on RUNKIT
const jsonata = require('jsonata');
const jsonataFunctions = require('jsonata-functions');
const expression = jsonata('$htmltotext("<p>Leadership has a dark side; a "leadership shadow" that often creates an unknown; lurking fear.</p>")');
jsonataFunctions.registerWithJSONATA(expression);
const result = expression.evaluate();
Parameters:
| Name | Type | Description |
|---|---|---|
expression |
Object | The JSONata Expression Object JSONata NPM |
Throws:
-
expression must be a JSONata expression object
- Type
- TypeError
(private, inner) shortenUuid(value, baseopt) → {String|Void}
- Source:
- See:
Example
Example usage within a JSONata transform
// returns
// result = '1m5otdkthiyq143crwujacdqg'
const jsonata = require('jsonata-extended');
const expr = jsonata('$shortenUuid("1b49aa30-e719-11e6-9835-f723b46a2688", "base36")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1m5otdkthiyq143crwujacdqg'
const jsonata = require('jsonata-extended');
const expr = jsonata('$shortenUuid("1b49aa30-e719-11e6-9835-f723b46a2688", "base36")');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
String | Properly formatted UUID | ||
base |
'base2' | 'base10' | 'base16' | 'base32' | 'base36' | 'base58' | 'base62' | 'base64' | 'base64url' |
<optional> |
'base36'
|
A valid base to use for the process, case sensitive Encoding Options |
Throws:
-
Will throw an error if the value is not a valid uuid
-
Will throw an error if the base is not a valid option
Returns:
- Type
- String | Void
(private, inner) truncate(valueopt, optionsopt) → {String|Void}
- Source:
Examples
Example usage within a JSONata transform for length of 13
// returns
// result = '1234567890...'
const jsonata = require('jsonata-extended');
const expr = jsonata('$truncate("1234567890123456789012345678901234567890", {"length": 13, "omission": "..."})');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1234567890...'
const jsonata = require('jsonata-extended');
const expr = jsonata('$truncate("1234567890123456789012345678901234567890", {"length": 13, "omission": "..."})');
const result = expr.evaluate();
Example usage within a JSONata transform for length of 20, and with a list of wordbreaks (these will be trimmed from end if present)
// returns
// result = '1234567890123456....'
const jsonata = require('jsonata-extended');
const expr = jsonata('$truncate('1234567890123456 , 789012345678901234567890', { 'length': 20 , 'omission': '...', 'wordbreakregex': '[\\\\s\\\\.%,:;\\\\?_]'})');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1234567890123456....'
const jsonata = require('jsonata-extended');
const expr = jsonata('$truncate('1234567890123456 , 789012345678901234567890', { 'length': 20 , 'omission': '...', 'wordbreakregex': '[\\\\s\\\\.%,:;\\\\?_]'})');
const result = expr.evaluate();
Example usage within a JSONata transform for length of 20, and with a single wordbreak (this will be trimmed from end if present)
// returns
// result = '1234567890123456....'
const jsonata = require('jsonata-extended');
const expr = jsonata('$truncate('1234567890123456 , 789012345678901234567890', { 'length': 20 , 'omission': '...', 'wordbreak': ' ' })');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1234567890123456....'
const jsonata = require('jsonata-extended');
const expr = jsonata('$truncate('1234567890123456 , 789012345678901234567890', { 'length': 20 , 'omission': '...', 'wordbreak': ' ' })');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String |
<optional> |
''
|
The string to truncate. | |||||||||||||||||||||||||
options |
Object |
<optional> |
{}
|
The options object.
Properties
|
Returns:
- Type
- String | Void
(private, inner) unicodeToASCII(valueopt, optionsopt) → {String|Void}
- Source:
- See:
Examples
Example usage within a JSONata transform
// returns
// result = 'Lorem 🤧 eripuit'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unicodeToASCII("Lörem 🤧 ëripuît")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = 'Lorem 🤧 eripuit'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unicodeToASCII("Lörem 🤧 ëripuît")');
const result = expr.evaluate();
Example usage within a JSONata transform with replacement of Unknown characters
// returns
// result = 'Lorem eripuit'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unicodeToASCII("Lörem 🤧 ëripuît", { "replacement": ""})');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = 'Lorem eripuit'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unicodeToASCII("Lörem 🤧 ëripuît", { "replacement": ""})');
const result = expr.evaluate();
Example usage within a JSONata transform with replacement of Unknown characters, most UNICODE characters are 2 bytes long the UTF8 Encoding for this emoji is 0xF0 0x9F 0xA4 0xA7
// returns
// result = 'Lorem XX eripuit'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unicodeToASCII("Lörem 🤧 ëripuît", { "replacement": "X"})');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = 'Lorem XX eripuit'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unicodeToASCII("Lörem 🤧 ëripuît", { "replacement": "X"})');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
String |
<optional> |
''
|
The UNICODE string to convert. | ||||||||||
options |
Object |
<optional> |
{}
|
The options object.
Properties
|
Returns:
- Type
- String | Void
(private, inner) unshortenUuid(value, baseopt) → {String|Void}
- Source:
- See:
Example
Example usage within a JSONata transform
// returns
// result = '1b49aa30-e719-11e6-9835-f723b46a2688'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unshortenUuid("1m5otdkthiyq143crwujacdqg", "base36")');
const result = expr.evaluate();
Try on RUNKIT
// returns
// result = '1b49aa30-e719-11e6-9835-f723b46a2688'
const jsonata = require('jsonata-extended');
const expr = jsonata('$unshortenUuid("1m5otdkthiyq143crwujacdqg", "base36")');
const result = expr.evaluate();
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
String | Shortened UUID | ||
base |
'base2' | 'base10' | 'base16' | 'base32' | 'base36' | 'base58' | 'base62' | 'base64' | 'base64url' |
<optional> |
'base36'
|
A valid base to use for the process, case sensitive Encoding Options |
Throws:
-
Will throw an error if the value is not a valid uuid
-
Will throw an error if the base is not a valid option
Returns:
- Type
- String | Void