express-ext 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -360,6 +360,15 @@ function escapeHTML(input) {
360
360
  return map[char]
361
361
  })
362
362
  }
363
+ exports.escapeHTML = escapeHTML
364
+ function generateChip(v) {
365
+ return '<div class="chip">' + escapeHTML(v) + '<span class="close" onclick="removeChip(event)"></span></div>'
366
+ }
367
+ exports.generateChip = generateChip
368
+ function generateChips(v) {
369
+ return !v ? "" : "" + v.map(generateChip).join("")
370
+ }
371
+ exports.generateChips = generateChips
363
372
  var s = "string"
364
373
  var o = "object"
365
374
  function escape(obj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-ext",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "express-ext",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -340,11 +340,17 @@ const map: StringMap = {
340
340
  "'": "&#39;",
341
341
  "`": "&#96;",
342
342
  }
343
- function escapeHTML(input: string): string {
343
+ export function escapeHTML(input: string): string {
344
344
  return input.replace(/[&<>"'`]/g, function (char) {
345
345
  return map[char]
346
346
  })
347
347
  }
348
+ export function generateChip(v: string): string {
349
+ return `<div class="chip">${escapeHTML(v)}<span class="close" onclick="removeChip(event)"></span></div>`
350
+ }
351
+ export function generateChips(v?: string[] | null): string {
352
+ return !v ? "" : `${v.map(generateChip).join("")}`
353
+ }
348
354
 
349
355
  const s = "string"
350
356
  const o = "object"