mirror of
https://github.com/JonasunderscoreJones/api.jonasjones.dev.git
synced 2025-10-23 12:09:19 +02:00
Initial commit (by create-cloudflare CLI)
This commit is contained in:
commit
58a42872a0
1745 changed files with 741893 additions and 0 deletions
6
node_modules/expand-template/.travis.yml
generated
vendored
Normal file
6
node_modules/expand-template/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 6
|
||||
- 8
|
||||
- 10
|
21
node_modules/expand-template/LICENSE
generated
vendored
Normal file
21
node_modules/expand-template/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Lars-Magnus Skog
|
||||
|
||||
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.
|
43
node_modules/expand-template/README.md
generated
vendored
Normal file
43
node_modules/expand-template/README.md
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# expand-template
|
||||
|
||||
> Expand placeholders in a template string.
|
||||
|
||||
[](https://www.npmjs.com/package/expand-template)
|
||||

|
||||
[](https://travis-ci.org/ralphtheninja/expand-template)
|
||||
[](https://standardjs.com)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm i expand-template -S
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Default functionality expands templates using `{}` as separators for string placeholders.
|
||||
|
||||
```js
|
||||
var expand = require('expand-template')()
|
||||
var template = '{foo}/{foo}/{bar}/{bar}'
|
||||
console.log(expand(template, {
|
||||
foo: 'BAR',
|
||||
bar: 'FOO'
|
||||
}))
|
||||
// -> BAR/BAR/FOO/FOO
|
||||
```
|
||||
|
||||
Custom separators:
|
||||
|
||||
```js
|
||||
var expand = require('expand-template')({ sep: '[]' })
|
||||
var template = '[foo]/[foo]/[bar]/[bar]'
|
||||
console.log(expand(template, {
|
||||
foo: 'BAR',
|
||||
bar: 'FOO'
|
||||
}))
|
||||
// -> BAR/BAR/FOO/FOO
|
||||
```
|
||||
|
||||
## License
|
||||
All code, unless stated otherwise, is dual-licensed under [`WTFPL`](http://www.wtfpl.net/txt/copying/) and [`MIT`](https://opensource.org/licenses/MIT).
|
26
node_modules/expand-template/index.js
generated
vendored
Normal file
26
node_modules/expand-template/index.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
module.exports = function (opts) {
|
||||
var sep = opts ? opts.sep : '{}'
|
||||
var len = sep.length
|
||||
|
||||
var whitespace = '\\s*'
|
||||
var left = escape(sep.substring(0, len / 2)) + whitespace
|
||||
var right = whitespace + escape(sep.substring(len / 2, len))
|
||||
|
||||
return function (template, values) {
|
||||
Object.keys(values).forEach(function (key) {
|
||||
var value = String(values[key]).replace(/\$/g, '$$$$')
|
||||
template = template.replace(regExp(key), value)
|
||||
})
|
||||
return template
|
||||
}
|
||||
|
||||
function escape (s) {
|
||||
return [].map.call(s, function (char) {
|
||||
return '\\' + char
|
||||
}).join('')
|
||||
}
|
||||
|
||||
function regExp (key) {
|
||||
return new RegExp(left + key + right, 'g')
|
||||
}
|
||||
}
|
29
node_modules/expand-template/package.json
generated
vendored
Normal file
29
node_modules/expand-template/package.json
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "expand-template",
|
||||
"version": "2.0.3",
|
||||
"description": "Expand placeholders in a template string",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ralphtheninja/expand-template.git"
|
||||
},
|
||||
"homepage": "https://github.com/ralphtheninja/expand-template",
|
||||
"scripts": {
|
||||
"test": "tape test.js && standard"
|
||||
},
|
||||
"keywords": [
|
||||
"template",
|
||||
"expand",
|
||||
"replace"
|
||||
],
|
||||
"author": "LM <ralphtheninja@riseup.net>",
|
||||
"license": "(MIT OR WTFPL)",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"standard": "^12.0.0",
|
||||
"tape": "^4.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
}
|
67
node_modules/expand-template/test.js
generated
vendored
Normal file
67
node_modules/expand-template/test.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
var test = require('tape')
|
||||
var Expand = require('./')
|
||||
|
||||
test('default expands {} placeholders', function (t) {
|
||||
var expand = Expand()
|
||||
t.equal(typeof expand, 'function', 'is a function')
|
||||
t.equal(expand('{foo}/{bar}', {
|
||||
foo: 'BAR', bar: 'FOO'
|
||||
}), 'BAR/FOO')
|
||||
t.equal(expand('{foo}{foo}{foo}', {
|
||||
foo: 'FOO'
|
||||
}), 'FOOFOOFOO', 'expands one placeholder many times')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('support for custom separators', function (t) {
|
||||
var expand = Expand({ sep: '[]' })
|
||||
t.equal(expand('[foo]/[bar]', {
|
||||
foo: 'BAR', bar: 'FOO'
|
||||
}), 'BAR/FOO')
|
||||
t.equal(expand('[foo][foo][foo]', {
|
||||
foo: 'FOO'
|
||||
}), 'FOOFOOFOO', 'expands one placeholder many times')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('support for longer custom separators', function (t) {
|
||||
var expand = Expand({ sep: '[[]]' })
|
||||
t.equal(expand('[[foo]]/[[bar]]', {
|
||||
foo: 'BAR', bar: 'FOO'
|
||||
}), 'BAR/FOO')
|
||||
t.equal(expand('[[foo]][[foo]][[foo]]', {
|
||||
foo: 'FOO'
|
||||
}), 'FOOFOOFOO', 'expands one placeholder many times')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('whitespace-insensitive', function (t) {
|
||||
var expand = Expand({ sep: '[]' })
|
||||
t.equal(expand('[ foo ]/[ bar ]', {
|
||||
foo: 'BAR', bar: 'FOO'
|
||||
}), 'BAR/FOO')
|
||||
t.equal(expand('[ foo ][ foo ][ foo]', {
|
||||
foo: 'FOO'
|
||||
}), 'FOOFOOFOO', 'expands one placeholder many times')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('dollar escape', function (t) {
|
||||
var expand = Expand()
|
||||
t.equal(expand('before {foo} after', {
|
||||
foo: '$'
|
||||
}), 'before $ after')
|
||||
t.equal(expand('before {foo} after', {
|
||||
foo: '$&'
|
||||
}), 'before $& after')
|
||||
t.equal(expand('before {foo} after', {
|
||||
foo: '$`'
|
||||
}), 'before $` after')
|
||||
t.equal(expand('before {foo} after', {
|
||||
foo: '$\''
|
||||
}), 'before $\' after')
|
||||
t.equal(expand('before {foo} after', {
|
||||
foo: '$0'
|
||||
}), 'before $0 after')
|
||||
t.end()
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue