mirror of
https://github.com/JonasunderscoreJones/api-worker.git
synced 2025-10-23 18:39: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
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')
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue