google-places-web
Version:
A simple wrapper for the Google Places Web API
45 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseSearch = void 0;
class BaseSearch {
constructor(opts) {
this._dev = false;
this._params = new Map();
if (opts) {
if (typeof opts !== 'object') {
throw new TypeError('search parameters are not an object');
}
Object.keys(opts).forEach((key) => this._params.set(key, opts[key]));
}
}
setDev(dev) {
this._dev = dev;
return this;
}
set(key, value) {
this._params.set(key, value);
return this;
}
get(key) {
return this._params.get(key);
}
remove(key) {
if (this._params.has(key)) {
this._params.delete(key);
return true;
}
return false;
}
toRequestJSON() {
const params = Array.from(this._params).reduce((obj, [key, value]) => {
obj[key] = value;
return obj;
}, {});
return params;
}
isValid() {
return true;
}
}
exports.BaseSearch = BaseSearch;
//# sourceMappingURL=BaseSearch.js.map