diff options
Diffstat (limited to 'node_modules/pupa')
-rw-r--r-- | node_modules/pupa/index.d.ts | 32 | ||||
-rw-r--r-- | node_modules/pupa/index.js | 39 | ||||
-rw-r--r-- | node_modules/pupa/license | 9 | ||||
-rw-r--r-- | node_modules/pupa/package.json | 47 | ||||
-rw-r--r-- | node_modules/pupa/readme.md | 63 |
5 files changed, 0 insertions, 190 deletions
diff --git a/node_modules/pupa/index.d.ts b/node_modules/pupa/index.d.ts deleted file mode 100644 index 762aae0..0000000 --- a/node_modules/pupa/index.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** -Simple micro templating. - -@param template - Text with placeholders for `data` properties. -@param data - Data to interpolate into `template`. - -@example -``` -import pupa = require('pupa'); - -pupa('The mobile number of {name} is {phone.mobile}', { - name: 'Sindre', - phone: { - mobile: '609 24 363' - } -}); -//=> 'The mobile number of Sindre is 609 24 363' - -pupa('I like {0} and {1}', ['🦄', '🐮']); -//=> 'I like 🦄 and 🐮' - -// Double braces encodes the HTML entities to avoid code injection -pupa('I like {{0}} and {{1}}', ['<br>🦄</br>', '<i>🐮</i>']); -//=> 'I like <br>🦄</br> and <i>🐮</i>' -``` -*/ -declare function pupa( - template: string, - data: unknown[] | {[key: string]: any} -): string; - -export = pupa; diff --git a/node_modules/pupa/index.js b/node_modules/pupa/index.js deleted file mode 100644 index 85739eb..0000000 --- a/node_modules/pupa/index.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; -const {htmlEscape} = require('escape-goat'); - -module.exports = (template, data) => { - if (typeof template !== 'string') { - throw new TypeError(`Expected a \`string\` in the first argument, got \`${typeof template}\``); - } - - if (typeof data !== 'object') { - throw new TypeError(`Expected an \`object\` or \`Array\` in the second argument, got \`${typeof data}\``); - } - - // The regex tries to match either a number inside `{{ }}` or a valid JS identifier or key path. - const doubleBraceRegex = /{{(\d+|[a-z$_][a-z\d$_]*?(?:\.[a-z\d$_]*?)*?)}}/gi; - - if (doubleBraceRegex.test(template)) { - template = template.replace(doubleBraceRegex, (_, key) => { - let result = data; - - for (const property of key.split('.')) { - result = result ? result[property] : ''; - } - - return htmlEscape(String(result)); - }); - } - - const braceRegex = /{(\d+|[a-z$_][a-z\d$_]*?(?:\.[a-z\d$_]*?)*?)}/gi; - - return template.replace(braceRegex, (_, key) => { - let result = data; - - for (const property of key.split('.')) { - result = result ? result[property] : ''; - } - - return String(result); - }); -}; diff --git a/node_modules/pupa/license b/node_modules/pupa/license deleted file mode 100644 index e7af2f7..0000000 --- a/node_modules/pupa/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/pupa/package.json b/node_modules/pupa/package.json deleted file mode 100644 index 399ce6f..0000000 --- a/node_modules/pupa/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "pupa", - "version": "2.1.1", - "description": "Simple micro templating", - "license": "MIT", - "repository": "sindresorhus/pupa", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "string", - "formatting", - "template", - "object", - "format", - "interpolate", - "interpolation", - "templating", - "expand", - "simple", - "replace", - "placeholders", - "values", - "transform", - "micro" - ], - "dependencies": { - "escape-goat": "^2.0.0" - }, - "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.7.2", - "xo": "^0.24.0" - } -} diff --git a/node_modules/pupa/readme.md b/node_modules/pupa/readme.md deleted file mode 100644 index bb9ab18..0000000 --- a/node_modules/pupa/readme.md +++ /dev/null @@ -1,63 +0,0 @@ -# pupa [![Build Status](https://travis-ci.org/sindresorhus/pupa.svg?branch=master)](https://travis-ci.org/sindresorhus/pupa) - -> Simple micro templating - -Useful when all you need is to fill in some placeholders. - - -## Install - -``` -$ npm install pupa -``` - - -## Usage - -```js -const pupa = require('pupa'); - -pupa('The mobile number of {name} is {phone.mobile}', { - name: 'Sindre', - phone: { - mobile: '609 24 363' - } -}); -//=> 'The mobile number of Sindre is 609 24 363' - -pupa('I like {0} and {1}', ['🦄', '🐮']); -//=> 'I like 🦄 and 🐮' - -// Double braces encodes the HTML entities to avoid code injection -pupa('I like {{0}} and {{1}}', ['<br>🦄</br>', '<i>🐮</i>']); -//=> 'I like <br>🦄</br> and <i>🐮</i>' -``` - - -## API - -### pupa(template, data) - -#### template - -Type: `string` - -Text with placeholders for `data` properties. - -#### data - -Type: `object | unknown[]` - -Data to interpolate into `template`. - - -## FAQ - -### What about template literals? - -Template literals expand on creation. This module expands the template on execution, which can be useful if either or both template and data are lazily created or user-supplied. - - -## Related - -- [pupa-cli](https://github.com/sindresorhus/pupa-cli) - CLI for this module |