Gathering detailed insights and metrics for obop
Gathering detailed insights and metrics for obop
npm install obop
Typescript
Module System
Node Version
NPM Version
JavaScript (95.99%)
Makefile (3.1%)
HTML (0.91%)
Total Downloads
5,023,154
Last Day
8,992
Last Week
39,285
Last Month
165,776
Last Year
1,743,629
12 Stars
87 Commits
1 Forks
4 Watching
7 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
obop@1.0.0
Unpacked Size
72.42 kB
Size
15.81 kB
File Count
14
NPM Version
10.9.0
Node Version
22.12.0
Publised On
15 Dec 2024
Cumulative downloads
Total Downloads
Last day
0.3%
8,992
Compared to previous day
Last week
-14%
39,285
Compared to previous week
Last month
7.9%
165,776
Compared to previous month
Last year
44%
1,743,629
Compared to previous year
MongoDB-style object operators makes array manipulation easy: where/order/update/view
1import obop from "obop"; 2 3const array = [{a: 1}, {a: 2}, {a: 3}]; 4 5const out = obop.where(array, {a: 2}); // => [ { a: 2 } ] 6 7const out = array.filter(obop.where({a: 2})); // => [ { a: 2 } ]
Alternatively, you can generate the original obop
function via the default export.
1import obopInit from "obop"; 2 3const obop = obopInit(); 4 5const out = obop.where(array, {a: 2}); // => [ { a: 2 } ]
1const obop = require('obop')(); 2 3const out = obop.where(array, {a: 2}); // => [ { a: 2 } ]
1<script src="obop.min.js"></script> 2<script> 3 const array = [{a: 1}, {a: 2}, {a: 3}]; 4 const out = obop.where(array, {a: 2}); // => [ { a: 2 } ] 5</script>
Download obop.min.js browser build of this module.
See document for more detail.
where() method supports the following query selectors:
1{ field: value } // equal to 2{ field: { $gt: value } } // greater than 3{ field: { $gte: value } } // greater than or equal to 4{ field: { $in: [value1, value2, ... ] } } // in 5{ field: { $lt: value } } // less than 6{ field: { $lte: value } } // less than or equal to 7{ field: { $ne: value } } // not equal to 8{ field: { $nin: [ value1, value2 ... ]} } // not in 9{ $or: [ { query1 }, { qury2 }, ... ] } // logical OR 10{ $and: [ { query1 }, { query2 }, ... ] } // logical AND 11{ field: { $not: { query } } } // not 12{ field: { $exists: boolean } } // exists 13{ field: { $size: value } } // array size
Example:
1const out1 = obop.where(array1, {genre: 'fruit', price: {$gt: 100, $gt: 200}}); 2const out2 = obop.where(array2, {'review.score': {$gte: 4.0}}); 3 4// OR 5const out1 = array1.filter(obop.where({genre: 'fruit', price: {$gt: 100, $gt: 200}})); 6const out2 = array2.filter(obop.where({'review.score': {$gte: 4.0}}));
order() method supports the following styles of sort parameters:
1{ field: 1 } // ascending 2{ field: -1 } // descending 3{ field1: 1, field2: -1, ... } // combination 4[ [ 'field1', 1 ], [ 'field2', -1 ], ... ] // array style
Example:
1obop.order(array1, {price: 1, stock: -1}); 2obop.order(array2, [['price', 1], ['stock', -1]]); // same as above 3 4// OR 5array1.sort(obop.order({price: 1, stock: -1})); 6array2.sort(obop.order([['price', 1], ['stock', -1]])); // same as above
update() method supports the following update operators:
1{ $set: { field: value } } // set value 2{ $unset: { field: '' } } // remove field 3{ $rename: { oldname: newname } } // rename field 4{ $inc: { field: amount } } // increment value 5{ $pull: { field: query } } // remove item from array 6{ $push: { field: value } } // add item to array
Example:
1obop.update(array1, {$inc: {stock: -1}, $set: {'review.score': 4}}); 2obop.update(array2, {$unset: {order: ''}}); 3 4// OR 5array1.forEach(obop.update({$inc: {stock: -1}, $set: {'review.score': 4}})); 6array2.forEach(obop.update({$unset: {order: ''}}));
view() method supports the following styles of projection parameters:
1{ field1: 1 } // output fields1 only 2{ field1: 1, field2: 1, ... } // output fields1, 2 and more 3{ field1: 0 } // output all fields except for fields1 4{ field1: 0, field2: 0, ... } // except fields1, 2 and more
Example:
1const out1 = obop.view(array1, {name: 1, price: 1, stock: 1}); // include fields 2const out2 = obop.view(array2, {_id: 0, secret: 0}); // exclude fields 3 4// OR 5const out1 = array1.map(obop.view({name: 1, price: 1, stock: 1})); // include fields 6const out2 = array2.map(obop.view({_id: 0, secret: 0})); // exclude fields
Copyright 2013-2024 @kawanet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More