force-lang 0.0.12 → 0.1.0

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/src/obj_utils.js CHANGED
@@ -1,18 +1,20 @@
1
- module.exports={
2
- stringify: function(obj, prop) {
3
- var placeholder = '____PLACEHOLDER____';
4
- var fns = [];
5
- var json = JSON.stringify(obj, function(key, value) {
6
- if (typeof value === 'function') {
7
- fns.push(value);
8
- return placeholder;
9
- }
10
- return value;
11
- }, 0);
12
- json = json.replace(new RegExp('"' + placeholder + '"', 'g'), function(_) {
13
- return fns.shift();
14
- });
15
- //return 'this["' + prop + '"] = ' + json + ';';
16
- return json;
17
- }
18
- }
1
+ export default {
2
+ stringify(obj, prop) {
3
+ const placeholder = '____PLACEHOLDER____';
4
+ const fns = [];
5
+ let json = JSON.stringify(
6
+ obj,
7
+ (key, value) => {
8
+ if (typeof value === 'function') {
9
+ fns.push(value);
10
+ return placeholder;
11
+ }
12
+ return value;
13
+ },
14
+ 0,
15
+ );
16
+ json = json.replace(new RegExp(`"${placeholder}"`, 'g'), _ => fns.shift());
17
+ // return 'this["' + prop + '"] = ' + json + ';';
18
+ return json;
19
+ },
20
+ };