This commit is contained in:
21
vscode-server-linux-x64-web/node_modules/expand-template/LICENSE
generated
vendored
Normal file
21
vscode-server-linux-x64-web/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.
|
26
vscode-server-linux-x64-web/node_modules/expand-template/index.js
generated
vendored
Normal file
26
vscode-server-linux-x64-web/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
vscode-server-linux-x64-web/node_modules/expand-template/package.json
generated
vendored
Normal file
29
vscode-server-linux-x64-web/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
vscode-server-linux-x64-web/node_modules/expand-template/test.js
generated
vendored
Normal file
67
vscode-server-linux-x64-web/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()
|
||||
})
|
Reference in New Issue
Block a user