New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

detect-coordinates

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-coordinates - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

3

lib/index.js

@@ -57,3 +57,4 @@ /* eslint complexity: 0 */

}
if (type.types[0].name !== 'Number') {
// support both promoted Number type and unpromoted Double, Decimal128 or Int32
if (!_.includes(['Number', 'Double', 'Int32', 'Decimal128'], type.types[0].name)) {
return false;

@@ -60,0 +61,0 @@ }

@@ -5,3 +5,3 @@ {

"author": "Thomas Rueckstiess <thomas@rueckstiess.net>",
"version": "0.1.0",
"version": "0.2.0",
"scripts": {

@@ -22,4 +22,4 @@ "fmt": "mongodb-js-fmt",

"devDependencies": {
"eslint-config-mongodb-js": "^1.0.6",
"mocha": "^2.3.4",
"eslint-config-mongodb-js": "^2.2.0",
"mocha": "^3.1.2",
"mongodb-js-fmt": "^0.0.3",

@@ -26,0 +26,0 @@ "mongodb-js-precommit": "^0.2.8",

@@ -14,7 +14,7 @@ # detect-coordinates [![travis][travis_img]][travis_url] [![npm][npm_img]][npm_url]

For this example, you need the mongodb node driver and mongodb-schema module
installed in addition to this module:
For this example, you need the `mongodb` node driver, `mongodb-schema` and
`lodash` modules installed in addition to this module:
```
npm install mongodb mongodb-schema detect-coordinates
npm install mongodb mongodb-schema detect-coordinates lodash
```

@@ -24,3 +24,3 @@

and looks at the first type of the first field to determine if it has
coordinates.
coordinates.

@@ -31,2 +31,3 @@ ```javascript

var detect = require('detect-coordinates');
var _ = require('lodash');

@@ -37,9 +38,9 @@ // connect to a MongoDB instance

// get the schema of the collection `test.docs`
parseSchema('test.test', db.collection('docs').find(), function(err, schema){
// get the schema of the collection `test.users` (only first 100 docs)
parseSchema('test.users', db.collection('users').find().limit(100), function(err, schema){
if(err) return console.error(err);
// serialize the schema and extract first type of first field
// serialize the schema and extract first type of field "last_position"
var plainSchema = schema.serialize();
var type = plainSchema.fields[0].types[0];
var type = _.find(plainSchema.fields, ['name', 'last_position']).types[0];

@@ -49,3 +50,3 @@ // check if that type represents geo coordinates

if (coordinates) {
console.log('type contains coordinates, here they are:', coordinates);
console.log('type contains coordinates, here they are:\n', coordinates);
} else {

@@ -59,2 +60,14 @@ console.log('type does not contain coordinates!');

This outputs:
```
type contains coordinates, here they are:
[ [ -73.98808416, 40.74854862 ],
[ -74.015756, 40.711512 ],
[ -74.0026376103, 40.7390169121 ],
[ -74.015756, 40.711512 ],
[ -73.96525063, 40.71044554 ],
...
```
## License

@@ -61,0 +74,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc