Verification parameter
- target: Original object
- conf: default value
let util = require('./index')
let data = {
number1: '1',
string1: 2,
boolean1: 'true',
object1: {a: 1},
array1: [1, 'a'],
database1: ';show tables',
anyone1: 'abc'
}
// int,str,bool,obj,arr,db They are Parameter Types
let {
int: {number1},
str: {string1},
bool: {boolean1},
obj: {object1},
arr: {array1},
db: {database1},
anyone1,
aab,
RESULT, // It is a mandatory parameter before it, after which it is an optional parameter
xyz,
} = util.pramProxy(data)
// let aab=1
console.log(number1, string1, boolean1, object1, array1, database1, anyone1, aab, RESULT, xyz)
----------------------------------------------------------------------------------------------
> node index.test.js
1 '2' true { a: 1 } [ 1, 'a' ] '\';show tables\'' 'abc' null 'aab is null or TYPE err' null
hot reloading code
let Node = (param) => {
console.log('real-time-func',param,12)
}
Node.id = 123
module.exports = Node
let util = require('./index')
util.hotReload(__dirname) // watch path
let d = require('./hot-reload')
if (!global.i) global.i = 1
setInterval(() => {
d(++global.i) // d(--global.i) Modify it
console.log('real-time-value',d.id)
}, 2000)
---------------------------------------------------------------------
> node index.test.js
real-time-func 666 12
real-time-value 123
hot reloaded C:\Users\Administrator\Desktop\git\utilify\index.test.js
real-time-func 66611 12
real-time-value 123
Experimental
require('babel-register')
require('babel-polyfill')
const path = require('path')
const util = require('./index')
const watch_path = path.join(__dirname, './src')
util.hotReload(watch_path)
// edit es6 code
import api from './src/api'
...
console.log proxy
let util = require('./index')
util.infoProxy()
console.log(123)
-----------------------------------------------------------------
> node index.test.js
123
at (C:\Users\Administrator\Desktop\git\utilify\index.test.js:38:9)
> node index.test.js
- More configuration items
- Hot updates when deleting files
- Join non-updateable configuration
- Remove references