@bbn/bbn 1.0.360 → 1.0.362

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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Replaces all new line characters '\ n' with html tag '<br>'.
3
+ *
4
+ * @method nl2br
5
+ * @global
6
+ *
7
+ * @example
8
+ * ```javascript
9
+ * bbn.fn.nl2br('hello \n world!');
10
+ * //"hello <br> world!"
11
+ * ```
12
+ * @memberof bbn.fn
13
+ * @param {Array!Object} st
14
+ * @param {String} [clsName]
15
+ * @returns {String}
16
+ */
17
+ export default function data2Html(data: any, clsName?: string): string;
@@ -0,0 +1,39 @@
1
+ import isArray from '../type/isArray.js';
2
+ import isObject from '../type/isObject.js';
3
+ /**
4
+ * Replaces all new line characters '\ n' with html tag '<br>'.
5
+ *
6
+ * @method nl2br
7
+ * @global
8
+ *
9
+ * @example
10
+ * ```javascript
11
+ * bbn.fn.nl2br('hello \n world!');
12
+ * //"hello <br> world!"
13
+ * ```
14
+ * @memberof bbn.fn
15
+ * @param {Array!Object} st
16
+ * @param {String} [clsName]
17
+ * @returns {String}
18
+ */
19
+ export default function data2Html(data, clsName) {
20
+ if (clsName === void 0) { clsName = ''; }
21
+ var isAssoc = !isArray(data);
22
+ var st = '<ul class="' + (clsName || 'bbn-ul') + '">';
23
+ for (var n in data) {
24
+ st += '<li>';
25
+ if (isAssoc) {
26
+ st += '<strong>' + n + '</strong>: ';
27
+ }
28
+ if (data[n] && (isArray(data[n]) || isObject(data[n]))) {
29
+ st += data2Html(data[n], clsName);
30
+ }
31
+ else {
32
+ st += data[n] === null ? '<em>null</em>' : (data[n].toString ? data[n].toString() : data[n]);
33
+ }
34
+ st += '</li>';
35
+ }
36
+ st += '</ul>';
37
+ return st;
38
+ }
39
+ ;
package/dist/fn.d.ts CHANGED
@@ -39,6 +39,7 @@ import count from './fn/object/count.js';
39
39
  import crc32 from './fn/string/crc32.js';
40
40
  import createObject from './fn/object/createObject.js';
41
41
  import cssExists from './fn/style/cssExists.js';
42
+ import data2Html from './fn/string/data2Html.js';
42
43
  import date from './fn/datetime/date.js';
43
44
  import dateSQL from './fn/datetime/dateSQL.js';
44
45
  import daysInMonth from './fn/datetime/daysInMonth.js';
@@ -281,6 +282,7 @@ declare const _default: {
281
282
  crc32: typeof crc32;
282
283
  createObject: typeof createObject;
283
284
  cssExists: typeof cssExists;
285
+ data2Html: typeof data2Html;
284
286
  date: typeof date;
285
287
  dateSQL: typeof dateSQL;
286
288
  daysInMonth: typeof daysInMonth;
package/dist/fn.js CHANGED
@@ -39,6 +39,7 @@ import count from './fn/object/count.js';
39
39
  import crc32 from './fn/string/crc32.js';
40
40
  import createObject from './fn/object/createObject.js';
41
41
  import cssExists from './fn/style/cssExists.js';
42
+ import data2Html from './fn/string/data2Html.js';
42
43
  import date from './fn/datetime/date.js';
43
44
  import dateSQL from './fn/datetime/dateSQL.js';
44
45
  import daysInMonth from './fn/datetime/daysInMonth.js';
@@ -281,6 +282,7 @@ export default {
281
282
  crc32: crc32,
282
283
  createObject: createObject,
283
284
  cssExists: cssExists,
285
+ data2Html: data2Html,
284
286
  date: date,
285
287
  dateSQL: dateSQL,
286
288
  daysInMonth: daysInMonth,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.360",
3
+ "version": "1.0.362",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",