aboutsummaryrefslogtreecommitdiff
path: root/node_modules/set-getter/index.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/set-getter/index.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/set-getter/index.js')
-rw-r--r--node_modules/set-getter/index.js83
1 files changed, 0 insertions, 83 deletions
diff --git a/node_modules/set-getter/index.js b/node_modules/set-getter/index.js
deleted file mode 100644
index ce9a6a0d4..000000000
--- a/node_modules/set-getter/index.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*!
- * set-getter (https://github.com/doowb/set-getter)
- *
- * Copyright (c) 2016, Brian Woodward.
- * Licensed under the MIT License.
- */
-
-'use strict';
-
-var toPath = require('to-object-path');
-
-/**
- * Defines a getter function on an object using property path notation.
- *
- * ```js
- * var obj = {};
- * getter(obj, 'foo', function() {
- * return 'bar';
- * });
- * ```
- * @param {Object} `obj` Object to add property to.
- * @param {String|Array} `prop` Property string or array to add.
- * @param {Function} `getter` Getter function to add as a property.
- * @api public
- */
-
-function setGetter(obj, prop, getter) {
- var key = toPath(arguments);
- return define(obj, key, getter);
-}
-
-/**
- * Define getter function on object or object hierarchy using dot notation.
- *
- * @param {Object} `obj` Object to define getter property on.
- * @param {String} `prop` Property string to define.
- * @param {Function} `getter` Getter function to define.
- * @return {Object} Returns original object.
- */
-
-function define(obj, prop, getter) {
- if (!~prop.indexOf('.')) {
- defineProperty(obj, prop, getter);
- return obj;
- }
-
- var keys = prop.split('.');
- var last = keys.pop();
- var target = obj;
- var key;
-
- while ((key = keys.shift())) {
- while (key.slice(-1) === '\\') {
- key = key.slice(0, -1) + '.' + keys.shift();
- }
- target = target[key] || (target[key] = {});
- }
-
- defineProperty(target, last, getter);
- return obj;
-}
-
-/**
- * Define getter function on object as a configurable and enumerable property.
- *
- * @param {Object} `obj` Object to define property on.
- * @param {String} `prop` Property to define.
- * @param {Function} `getter` Getter function to define.
- */
-
-function defineProperty(obj, prop, getter) {
- Object.defineProperty(obj, prop, {
- configurable: true,
- enumerable: true,
- get: getter
- });
-}
-
-/**
- * Expose `setGetter`
- */
-
-module.exports = setGetter;