+72
-5
@@ -55,2 +55,5 @@ 'use strict'; | ||
| value: function versionCompare(a, b) { | ||
| if (!a) return -1; | ||
| if (!b) return 1; | ||
| var _a = a.version.split('.'); | ||
@@ -102,2 +105,6 @@ var _b = b.version.split('.'); | ||
| value: function applyAction(preset, action) { | ||
| var _keyArray = undefined; | ||
| var _keys = undefined; | ||
| var _pointer = undefined; | ||
| switch (action.type) { | ||
@@ -137,7 +144,7 @@ case 'move': | ||
| case 'remove': | ||
| var _keys = action.key.split('.'); | ||
| var pointer = preset; | ||
| _keys = action.key.split('.'); | ||
| _pointer = preset; | ||
| _keys.forEach(function (key, index) { | ||
| var save = pointer[key]; | ||
| var save = _pointer[key]; | ||
| if (save == null) { | ||
@@ -147,7 +154,67 @@ return; | ||
| if (index === _keys.length - 1) { | ||
| delete pointer[key]; | ||
| delete _pointer[key]; | ||
| } | ||
| pointer = save; | ||
| _pointer = save; | ||
| }); | ||
| break; | ||
| case 'create': | ||
| _keyArray = action.keys; | ||
| if (!_keyArray) { | ||
| _keyArray = {}; | ||
| _keyArray[action.key] = action.value; | ||
| } | ||
| var _loop = function _loop(actionKey) { | ||
| _keys = actionKey.split('.'); | ||
| _pointer = preset; | ||
| _keys.forEach(function (key, index) { | ||
| if (index === _keys.length - 1) { | ||
| _pointer[key] = _keyArray[actionKey] || {}; | ||
| } else { | ||
| if (_pointer[key] == null) { | ||
| _pointer[key] = {}; | ||
| } | ||
| _pointer = _pointer[key]; | ||
| } | ||
| }); | ||
| }; | ||
| for (var actionKey in _keyArray) { | ||
| _loop(actionKey); | ||
| } | ||
| break; | ||
| case 'add-to-array': | ||
| _keyArray = action.keys; | ||
| if (!_keyArray) { | ||
| _keyArray = {}; | ||
| _keyArray[action.key] = action.value; | ||
| } | ||
| var _loop2 = function _loop2(actionKey) { | ||
| _keys = actionKey.split('.'); | ||
| _pointer = preset; | ||
| _keys.forEach(function (key, index) { | ||
| if (index === _keys.length - 1) { | ||
| if (_pointer[key]) { | ||
| if (!_pointer[key].length) { | ||
| _pointer[key].push(_keyArray[actionKey]); | ||
| } | ||
| } else { | ||
| _pointer[key] = [_keyArray[actionKey]]; | ||
| } | ||
| } else { | ||
| if (_pointer[key] == null) { | ||
| _pointer[key] = {}; | ||
| } | ||
| _pointer = _pointer[key]; | ||
| } | ||
| }); | ||
| }; | ||
| for (var actionKey in _keyArray) { | ||
| _loop2(actionKey); | ||
| } | ||
| break; | ||
| case 'custom': | ||
@@ -154,0 +221,0 @@ preset = action.run(preset); |
| # Changelog | ||
| ## 0.0.2 | ||
| - added types `create` and `add-to-array` | ||
| ## 0.0.1 | ||
@@ -4,0 +7,0 @@ - added types `move`, `remove` and `custom` |
+18
-3
@@ -7,8 +7,22 @@ var verjson = require('./source'); | ||
| { | ||
| type: 'custom', | ||
| run: function (old) { | ||
| return old; | ||
| type: 'create', | ||
| value: 'NEW', | ||
| key: 'something.new' | ||
| }, { | ||
| type: 'create', | ||
| keys: { | ||
| woah: { | ||
| info: 'Objects!' | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| '2.0.0': [ | ||
| { | ||
| type: 'add-to-array', | ||
| keys: { | ||
| array: 'arrayData' | ||
| } | ||
| } | ||
| ], | ||
| '0.0.2': [ | ||
@@ -46,2 +60,3 @@ { | ||
| value: 'attack', | ||
| array: [], | ||
| complexData: { | ||
@@ -48,0 +63,0 @@ key: { |
+1
-1
| { "name": "verjson" | ||
| , "description": "Applies format changes to keep old jsons compatible." | ||
| , "version": "0.0.1" | ||
| , "version": "0.0.2" | ||
| , "license": "MIT" | ||
@@ -5,0 +5,0 @@ , "author": "Florian Wendelborn" |
+64
-5
@@ -30,2 +30,5 @@ import {EventEmitter} from 'events'; | ||
| versionCompare (a, b) { | ||
| if (!a) return -1; | ||
| if (!b) return 1; | ||
| let _a = a.version.split('.'); | ||
@@ -73,2 +76,6 @@ let _b = b.version.split('.'); | ||
| applyAction (preset, action) { | ||
| let _keyArray; | ||
| let _keys; | ||
| let _pointer; | ||
| switch (action.type) { | ||
@@ -102,7 +109,7 @@ case 'move': | ||
| case 'remove': | ||
| let _keys = action.key.split('.'); | ||
| let pointer = preset; | ||
| _keys = action.key.split('.'); | ||
| _pointer = preset; | ||
| _keys.forEach((key, index) => { | ||
| let save = pointer[key]; | ||
| let save = _pointer[key]; | ||
| if (save == null) { | ||
@@ -112,7 +119,59 @@ return; | ||
| if (index === _keys.length - 1) { | ||
| delete pointer[key]; | ||
| delete _pointer[key]; | ||
| } | ||
| pointer = save; | ||
| _pointer = save; | ||
| }); | ||
| break; | ||
| case 'create': | ||
| _keyArray = action.keys; | ||
| if (!_keyArray) { | ||
| _keyArray = {}; | ||
| _keyArray[action.key] = action.value; | ||
| } | ||
| for (let actionKey in _keyArray) { | ||
| _keys = actionKey.split('.'); | ||
| _pointer = preset; | ||
| _keys.forEach((key, index) => { | ||
| if (index === _keys.length - 1) { | ||
| _pointer[key] = _keyArray[actionKey] || {}; | ||
| } else { | ||
| if (_pointer[key] == null) { | ||
| _pointer[key] = {}; | ||
| } | ||
| _pointer = _pointer[key]; | ||
| } | ||
| }); | ||
| } | ||
| break; | ||
| case 'add-to-array': | ||
| _keyArray = action.keys; | ||
| if (!_keyArray) { | ||
| _keyArray = {}; | ||
| _keyArray[action.key] = action.value; | ||
| } | ||
| for (let actionKey in _keyArray) { | ||
| _keys = actionKey.split('.'); | ||
| _pointer = preset; | ||
| _keys.forEach((key, index) => { | ||
| if (index === _keys.length - 1) { | ||
| if (_pointer[key]) { | ||
| if (!_pointer[key].length) { | ||
| _pointer[key].push(_keyArray[actionKey]); | ||
| } | ||
| } else { | ||
| _pointer[key] = [_keyArray[actionKey]]; | ||
| } | ||
| } else { | ||
| if (_pointer[key] == null) { | ||
| _pointer[key] = {}; | ||
| } | ||
| _pointer = _pointer[key]; | ||
| } | ||
| }); | ||
| } | ||
| break; | ||
| case 'custom': | ||
@@ -119,0 +178,0 @@ preset = action.run(preset); |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
15148
25.39%419
43.49%