1 | import flatten from 'flat';
|
2 |
|
3 | function OBJFlatten(data, feed) {
|
4 | const opts = {
|
5 | delimiter: this.getParam('separator', '/'),
|
6 | safe: this.getParam('safe', true),
|
7 | };
|
8 | if (this.isLast()) {
|
9 | feed.close();
|
10 | } else {
|
11 | feed.send(flatten(data, opts));
|
12 | }
|
13 | }
|
14 |
|
15 | /**
|
16 | * Take `Object` and flat it with delimited character.
|
17 | *
|
18 | * @name OBJFlatten
|
19 | * @alias flatten
|
20 | * @param {String} [separator=/] choose a character for flatten keys
|
21 | * @param {Boolean} [safe=false] preserve arrays and their contents,
|
22 | * @returns {Object}
|
23 | * @see https://www.npmjs.com/package/flat
|
24 | */
|
25 | export default {
|
26 | OBJFlatten,
|
27 | };
|