tastypie
Version:
Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces
24 lines (18 loc) • 490 B
JavaScript
var has = require('./has');
/**
* Unset object property.
*/
function unset(obj, prop){
if (has(obj, prop)) {
var parts = prop.split('.'),
last = parts.pop();
while (prop = parts.shift()) {
obj = obj[prop];
}
return (delete obj[last]);
} else {
// if property doesn't exist treat as deleted
return true;
}
}
module.exports = unset;