Skip to content

Commit

Permalink
$length now handles .count, .count(), .size, .size(),
Browse files Browse the repository at this point in the history
`.length`.
  • Loading branch information
anywhichway committed Feb 15, 2019
1 parent bca0629 commit c0c90b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ $year - `{<property>: {$year: number year}}`

## Updates

2019-02-15 v2.03b - `$length` now handles `.count`, `.count()`, `.size`, `.size()`, `.length`.

2019-02-12 v2.03b - All functions now have basic documentation.

2019-02-11 v2.02b - Lots of documentation. Started deprecation on method name `.match` in favor of `.query`, but both will work for now through aliasing.
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,12 @@
this[as||key] = iterable.length
} else if(typeof(iterable.count)==="function") {
this[as||key] = iterable.count();
} else if(typeof(iterable.count)==="number") {
this[as||key] = iterable.count;
} else if(typeof(iterable.size)==="function") {
this[as||key] = iterable.size();
} else if(typeof(iterable.size)==="number") {
this[as||key] = iterable.size;
} else {
let count = 0;
for(let value of iterable) {
Expand Down Expand Up @@ -778,7 +782,7 @@
return /^\d{3}-?\d{2}-?\d{4}$/.test(value);
},
$length(value,length) {
return a && a.length===length;
return a && (a.length===length || a.size===length);
},
$lock(value,_,key) {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "joqular",
"version": "2.0.3b",
"version": "2.0.4b",
"description": "JOQULAR (JavaScript Object Query Language Representation) for JSON data matching, transformation, validation and extraction",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c0c90b1

Please sign in to comment.