本文整理汇总了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);
},