UNPKG

sails-service-location

Version:

Service for Sails framework with Location features

82 lines (63 loc) 2.25 kB
'use strict'; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); Object.defineProperty(exports, "__esModule", { value: true }); var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var BaseLocation = function () { function BaseLocation(_config) { _classCallCheck(this, BaseLocation); this._config = {}; this._provider = {}; _lodash2.default.assign(this._config, _config); } /** * Get configuration value * @param {String} [path] * @returns {*} */ _createClass(BaseLocation, [{ key: 'get', value: function get(path) { return typeof path === 'undefined' ? this._config : _lodash2.default.get(this._config, path); } /** * Set configuration value * @param {String} path * @param {*} value * @returns {BaseLocation} */ }, { key: 'set', value: function set(path, value) { _lodash2.default.set(this._config, path, value); return this; } /** * Get location provider * @returns {*} */ }, { key: 'getProvider', value: function getProvider() { return this._provider; } /** * Set new provider * @param {*} provider * @returns {BaseLocation} */ }, { key: 'setProvider', value: function setProvider(provider) { this._provider = provider; return this; } }]); return BaseLocation; }(); exports.default = BaseLocation; module.exports = exports['default'];