@karmaniverous/jsonmap 0.0.6 → 0.0.7
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/README.md
CHANGED
|
@@ -103,8 +103,8 @@ Once a `JsonMap` instance is configured, it can be executed against any input. C
|
|
|
103
103
|
```js
|
|
104
104
|
import { JsonMap } from '@karmaniverous/jsonmap';
|
|
105
105
|
|
|
106
|
-
// Assumes
|
|
107
|
-
const jsonMap = new JsonMap(
|
|
106
|
+
// Assumes map & lib are already defined as above.
|
|
107
|
+
const jsonMap = new JsonMap(map, lib);
|
|
108
108
|
|
|
109
109
|
// Assumes some input data object is already defined.
|
|
110
110
|
const output = await jsonMap.transform(input);
|
|
@@ -122,19 +122,19 @@ JsonMap class to apply transformations to a JSON object
|
|
|
122
122
|
**Kind**: global class
|
|
123
123
|
|
|
124
124
|
* [JsonMap](#JsonMap)
|
|
125
|
-
* [new JsonMap(
|
|
125
|
+
* [new JsonMap([map], [lib])](#new_JsonMap_new)
|
|
126
126
|
* [.transform(input)](#JsonMap+transform) ⇒ <code>object</code>
|
|
127
127
|
|
|
128
128
|
<a name="new_JsonMap_new"></a>
|
|
129
129
|
|
|
130
|
-
### new JsonMap(
|
|
130
|
+
### new JsonMap([map], [lib])
|
|
131
131
|
Creates an instance of JsonMap.
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
| Param | Type | Description |
|
|
135
135
|
| --- | --- | --- |
|
|
136
|
-
|
|
|
137
|
-
|
|
|
136
|
+
| [map] | <code>object</code> | The data mapping configuration. |
|
|
137
|
+
| [lib] | <code>object</code> | A collection of function libraries. |
|
|
138
138
|
|
|
139
139
|
<a name="JsonMap+transform"></a>
|
|
140
140
|
|
|
@@ -26,14 +26,16 @@ class JsonMap {
|
|
|
26
26
|
/**
|
|
27
27
|
* Creates an instance of JsonMap.
|
|
28
28
|
*
|
|
29
|
-
* @param {object}
|
|
30
|
-
* @param {object}
|
|
29
|
+
* @param {object} [map] - The data mapping configuration.
|
|
30
|
+
* @param {object} [lib] - A collection of function libraries.
|
|
31
31
|
*/
|
|
32
|
-
constructor(
|
|
32
|
+
constructor() {
|
|
33
|
+
let map = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
34
|
+
let lib = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
35
|
_classPrivateMethodInitSpec(this, _resolvePath);
|
|
34
36
|
_classPrivateMethodInitSpec(this, _transform);
|
|
35
|
-
this.lib = lib;
|
|
36
37
|
this.map = map;
|
|
38
|
+
this.lib = lib;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/**
|
package/lib/JsonMap/JsonMap.js
CHANGED
|
@@ -16,12 +16,12 @@ class JsonMap {
|
|
|
16
16
|
/**
|
|
17
17
|
* Creates an instance of JsonMap.
|
|
18
18
|
*
|
|
19
|
-
* @param {object}
|
|
20
|
-
* @param {object}
|
|
19
|
+
* @param {object} [map] - The data mapping configuration.
|
|
20
|
+
* @param {object} [lib] - A collection of function libraries.
|
|
21
21
|
*/
|
|
22
|
-
constructor(
|
|
23
|
-
this.lib = lib;
|
|
22
|
+
constructor(map = {}, lib = {}) {
|
|
24
23
|
this.map = map;
|
|
24
|
+
this.lib = lib;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|