UNPKG

jsonata-extended

Version:
117 lines (83 loc) 5.64 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jsonata-extended.js - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <script src="scripts/nav.js" defer></script> <script src="https://embed.runkit.com"></script> <style>.embedrunkit { overflow: visible; }</style> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav > <input type="text" id="nav-search" placeholder="Search" /> <h2><a href="index.html">Home</a></h2><h2><a href="https://github.com/martinholden-skillsoft/jsonata-extended.git" target="_blank" class="menu-item" id="repository" >Github repo</a></h2><h3>Modules</h3><ul><li><a href="module-jsonata-functions.html">jsonata-functions</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~decodeUuid">decodeUuid</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~encodeUuid">encodeUuid</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~htmltotext">htmltotext</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~languageInfo">languageInfo</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~moment">moment</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~momentDuration">momentDuration</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~mustache">mustache</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~parsePath">parsePath</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~parseUrl">parseUrl</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~registerWithJSONATA">registerWithJSONATA</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~shortenUuid">shortenUuid</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~truncate">truncate</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~unicodeToASCII">unicodeToASCII</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~unshortenUuid">unshortenUuid</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#jsonataExtended">jsonataExtended</a></li></ul> </nav> <div id="main"> <h1 class="page-title">jsonata-extended.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>const jsonataOriginal = require('jsonata'); const jsonataFunctions = require('./jsonata-functions'); /** * Return a JSONata expression object that includes the custom functions registered * * @param {Object} expr - JSONata expression {@link https://www.npmjs.com/package/jsonata|JSONata NPM} * @param {Object} options * @param {boolean} options.recover: attempt to recover on parse error * @param {Function} options.RegexEngine: RegEx class constructor to use * @example &lt;caption>Example using the extended JSONata as a dropin replacement for the standard {@link https://www.npmjs.com/package/jsonata|JSONata NPM}&lt;/caption> * // const jsonata = require('jsonata'); * const jsonata = require('jsonata-extended'); * const expr = jsonata('$htmltotext("&lt;p>Leadership has a dark side; a &amp;#34;leadership shadow&amp;#34; that often creates an unknown; lurking fear.&lt;/p>")'); * const result = expr.evaluate(); * @see {@link https://www.npmjs.com/package/jsonata|JSONata NPM} * @returns {{evaluate: evaluate, assign: assign, registerFunction: registerFunction, * ast: ast, errors: errors}} Evaluated expression */ function jsonataExtended(expr, options) { const expression = jsonataOriginal(expr, options); jsonataFunctions.registerWithJSONATA(expression); return expression; } module.exports = jsonataExtended; </code></pre> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/polyfill.js"></script> <script src="scripts/linenumber.js"></script> <script src="scripts/search.js" defer></script> <script src="scripts/collapse.js" defer></script> <script> const elements = [...document.getElementsByClassName('embedrunkit')] const notebooks = elements.reduce((notebooks, element) => { const innerText = element.firstChild const currentCell = window.RunKit.createNotebook({ element, nodeVersion:"12.x.x", source: innerText.textContent, // Remove the text content of the pre tag after the embed has loaded onLoad: () => innerText.remove() }) return notebooks }, [])</script> </body> </html>