本文整理匯總了TypeScript中jsesc.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
export default function(str: string): string {
return jsesc(str, { wrap: true });
};
示例2: async
app.get('*', async (req, res, next) => {
// Try to answer request using a rendered statecraft store
const key = url.parse(req.url).pathname!.slice(1)
// console.log('key', key)
const result = await store.fetch({type: I.QueryType.KV, q: new Set([key])})
// console.log('result', result)
let value = result.results.get(key)
if (value == null) return next()
res.setHeader('content-type', 'text/html')
res.setHeader('x-sc-version', JSON.stringify(result.versions))
// TODO: generate an etag based off the version, and parse it back to pass to fetch.
const versionRange = result.versions
const versions: I.FullVersion = vRangeTo(versionRange)
const mimetype = Buffer.isBuffer(value) ? 'image/png' : 'application/json'
// if (Buffer.isBuffer(value)) value = value.toString('base64')
if (Buffer.isBuffer(value)) value = `data:${mimetype};base64,${value.toString('base64')}`
// const v = Buffer.isBuffer(value) ? value.toString('base64') : value
res.send(`<!doctype html>
<div id=content>${render(mimetype, value).toString()}</div>
<script>
const Buffer = {from(arr) { return new Uint8Array(arr) }};
const config = ${jsesc({
mimetype,
key,
initialValue: value,
initialVersions: versions
} as any)}
</script>
<script src="/bundle.js"></script>
`)
})
示例3: jsesc
return str.replace(escapableExp, function (a) {
var c = meta[a];
if (typeof c === 'string') {
return c;
}
//return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
return jsesc(a, jsonNW);
});
示例4: genEtag
const renderEditor = (value: string | null, key: I.Key, versions: I.FullVersion): HTMLDocData => (
{
headers: {
// 'x-sc-version': JSON.stringify(versions),
'etag': genEtag(key, versions),
'content-type': 'text/html',
},
data: `<!doctype html>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="/editorstyle.css">
<textarea id=content autofocus>${value || ''}</textarea>
<div id=connstatus></div>
<script>
const config = ${jsesc({
key,
initialValue: value,
initialVersions: bakeVersions(versions)
} as any)}
</script>
<script src="/bundle.js"></script>
`
}
)
示例5: jsesc
escape: function(pat: string){
return jsesc(pat);
},