Comparing version 1.0.3 to 1.1.0
@@ -105,5 +105,3 @@ 'use strict'; | ||
value: function appendCriteria(criteria) { | ||
this._criteria.push({ | ||
criteria: criteria | ||
}); | ||
this._criteria.push(criteria); | ||
return this; | ||
@@ -135,5 +133,10 @@ } | ||
var criteriaMap = this._criteria.map(function (item) { | ||
if (item.criteria != null) { | ||
return '(' + item.criteria.toString() + ')'; | ||
if (typeof item === 'string') { | ||
return '(' + item + ')'; | ||
} | ||
if (item instanceof Quri || !item.field || !item.operator) { | ||
return '(' + item.toString() + ')'; | ||
} | ||
var fieldString = JSON.stringify(item.field); | ||
@@ -181,4 +184,6 @@ var operatorString = Quri.operatorToString(item.operator); | ||
if (item.criteria != null) { | ||
object.criteria.push(item.criteria.toJS(options)); | ||
if (item instanceof Quri) { | ||
object.criteria.push(item.toJS(options)); | ||
} else if (typeof item === 'string' || !item.field || !item.operator) { | ||
object.criteria.push(item); | ||
} else { | ||
@@ -254,2 +259,6 @@ var field = item.field; | ||
value: function fromJS(object) { | ||
if (!object) { | ||
return new Quri(); | ||
} | ||
var quri = new Quri(object.conjunction); | ||
@@ -265,9 +274,7 @@ | ||
if (item.criteria) { | ||
// Assume objects with a criteria property | ||
// should become Quri instances. | ||
var innerQuri = Quri.fromJS(item); | ||
quri.appendQuri(innerQuri); | ||
} else if (item.field) { | ||
if (item instanceof Quri || item.criteria) { | ||
// Clone quri instances with fromJS to avoid mutating data. | ||
// Assume any objects with a criteria property should become Quri instances. | ||
quri.appendQuri(Quri.fromJS(item)); | ||
} else if (item.field && item.operator) { | ||
// Assume an expression object | ||
@@ -279,4 +286,4 @@ var field = item.field; | ||
quri.appendExpression(field, operator, value); | ||
} else if (item.length === 3) { | ||
// Assume an iterable with 3 items is an expression. | ||
} else if (Array.isArray(item) && item.length === 3) { | ||
// Assume an array with 3 items is an expression. | ||
@@ -291,3 +298,3 @@ var _item = _slicedToArray(item, 3); | ||
} else { | ||
// Assume anything else is a criteria object. | ||
// Assume anything else is a string or toString-able criteria object. | ||
quri.appendCriteria(item); | ||
@@ -294,0 +301,0 @@ } |
{ | ||
"name": "quri", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "JS wrapper for the QURI string specification", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18016
325
0