Skip to content

Commit 18d635a

Browse files
committed
init
0 parents  commit 18d635a

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
.DS_Store*
3+
*.log
4+
*.gz
5+
6+
node_modules
7+
coverage

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_js:
2+
- "0.10"
3+
- "0.11"
4+
language: node_js
5+
script: "npm run-script test-travis"
6+
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014 Jonathan Ong [email protected]
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# oids-equal
3+
4+
[![NPM version][npm-image]][npm-url]
5+
[![build status][travis-image]][travis-url]
6+
[![Test coverage][coveralls-image]][coveralls-url]
7+
[![Gittip][gittip-image]][gittip-url]
8+
9+
[npm-image]: https://img.shields.io/npm/v/oids-equal.svg?style=flat
10+
[npm-url]: https://npmjs.org/package/oids-equal
11+
[travis-image]: https://img.shields.io/travis/mongodb-utils/oids-equal.svg?style=flat
12+
[travis-url]: https://travis-ci.org/mongodb-utils/oids-equal
13+
[coveralls-image]: https://img.shields.io/coveralls/mongodb-utils/oids-equal.svg?style=flat
14+
[coveralls-url]: https://coveralls.io/r/mongodb-utils/oids-equal?branch=master
15+
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat
16+
[gittip-url]: https://www.gittip.com/jonathanong/

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
module.exports = function (arr1, arr2) {
3+
if (!arr1 || !arr2) return false
4+
var length = arr1.length
5+
if (length !== arr2.length) return false
6+
for (var i = 0; i < length; i++)
7+
if (!arr1[i].equals(arr2[i]))
8+
return false
9+
return true
10+
}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "oids-equal",
3+
"description": "check if two arrays of ObjectIDs are equal",
4+
"version": "1.0.0",
5+
"author": {
6+
"name": "Jonathan Ong",
7+
"email": "[email protected]",
8+
"url": "http://jongleberry.com",
9+
"twitter": "https://twitter.com/jongleberry"
10+
},
11+
"license": "MIT",
12+
"repository": "mongodb-utils/oids-equal",
13+
"dependencies": {},
14+
"devDependencies": {
15+
"mongodb": "1",
16+
"mocha": "1",
17+
"istanbul": "0"
18+
},
19+
"scripts": {
20+
"test": "mocha --reporter spec",
21+
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
22+
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
23+
},
24+
"keywords": [
25+
"mongodb",
26+
"objectid",
27+
"oid",
28+
"equal"
29+
],
30+
"files": ["index.js"]
31+
}

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
var ObjectID = require('mongodb').ObjectID
3+
var assert = require('assert')
4+
5+
var equal = require('./')
6+
7+
describe('OIDs Equal', function () {
8+
it('should return false if not equal', function () {
9+
assert(!equal([new ObjectID()], [new ObjectID(), new ObjectID()]))
10+
})
11+
12+
it('should return true if equal', function () {
13+
var arr = [new ObjectID(), new ObjectID()]
14+
assert(equal(arr, arr.slice()))
15+
})
16+
})

0 commit comments

Comments
 (0)