pelias-query
Advanced tools
Comparing version 9.15.2 to 9.16.0
@@ -17,3 +17,3 @@ | ||
var check = require('check-types'); | ||
const _ = require('lodash'); | ||
@@ -25,3 +25,3 @@ function Variable(){ | ||
Variable.prototype.set = function( val ){ | ||
if( !check.nonEmptyString(val) && !check.number(val) && !check.boolean(val) && !check.array(val) && !check.object(val)){ | ||
if( val === '' || val === null || val === undefined ){ | ||
throw new Error( 'invalid value, value must be valid js Variable' ); | ||
@@ -28,0 +28,0 @@ } |
@@ -8,8 +8,9 @@ | ||
var check = require('check-types'), | ||
Variable = require('./Variable'); | ||
const _ = require('lodash'); | ||
const Variable = require('./Variable'); | ||
function VariableStore( vars ){ | ||
this._vars = {}; | ||
if( check.assigned( vars ) ){ | ||
if( !_.isEmpty( vars ) ){ | ||
this.set( vars ); | ||
@@ -35,3 +36,3 @@ } | ||
VariableStore.prototype.var = function( key, val ){ | ||
if( !check.nonEmptyString( key ) ){ | ||
if( _.isEmpty( key ) || !_.isString( key) ) { | ||
throw new Error( 'invalid query variable, key must be valid string' ); | ||
@@ -43,6 +44,8 @@ } | ||
} | ||
// setter | ||
if( check.assigned( val ) ){ | ||
// set value if val parameter passed | ||
if (val !== undefined) { | ||
this._vars[ key ].set( val ); | ||
} | ||
// getter | ||
@@ -56,3 +59,3 @@ return this._vars[ key ]; | ||
VariableStore.prototype.isset = function( key ){ | ||
if( !check.nonEmptyString( key ) ){ | ||
if( _.isEmpty( key ) || !_.isString( key) ) { | ||
throw new Error( 'invalid key, must be valid string' ); | ||
@@ -72,3 +75,3 @@ } | ||
VariableStore.prototype.unset = function( key ){ | ||
if( !check.nonEmptyString( key ) ){ | ||
if( _.isEmpty( key ) || !_.isString( key) ) { | ||
throw new Error( 'invalid key, must be valid string' ); | ||
@@ -89,3 +92,3 @@ } | ||
VariableStore.prototype.set = function( pojo ){ | ||
if( !check.object( pojo ) ){ | ||
if( !_.isPlainObject( pojo ) ){ | ||
throw new Error( 'invalid object' ); | ||
@@ -92,0 +95,0 @@ } |
{ | ||
"name": "pelias-query", | ||
"version": "9.15.2", | ||
"version": "9.16.0", | ||
"description": "An Elasticsearch query builder for Pelias", | ||
@@ -27,3 +27,2 @@ "engines": { | ||
"dependencies": { | ||
"check-types": "^8.0.0", | ||
"lodash": "^4.17.14" | ||
@@ -30,0 +29,0 @@ }, |
1
308541
- Removedcheck-types@^8.0.0
- Removedcheck-types@8.0.3(transitive)