clear.js 268 B

12345678910111213141516
  1. 'use strict';
  2. var keys = require('./keys');
  3. module.exports = function (obj) {
  4. var error;
  5. keys(obj).forEach(function (key) {
  6. try {
  7. delete this[key];
  8. } catch (e) {
  9. if (!error) error = e;
  10. }
  11. }, obj);
  12. if (error !== undefined) throw error;
  13. return obj;
  14. };