uni-ticket-system/node_modules/licia/safeDel.js

17 lines
373 B
JavaScript
Raw Normal View History

2023-12-05 02:11:10 +00:00
var isUndef = require('./isUndef');
var castPath = require('./castPath');
exports = function(obj, path) {
path = castPath(path, obj);
var prop, ret;
while ((prop = path.shift())) {
ret = obj[prop];
if (path.length === 0) delete obj[prop];
obj = ret;
if (isUndef(obj)) return;
}
return ret;
};
module.exports = exports;