Skip to content

Commit

Permalink
Mmdb support (#36)
Browse files Browse the repository at this point in the history
* Introduce database format detector

* Move current codebase to legacy/

* Kinda works

* Going further

* Make it faster

* .. and even faster..

* Decoder test

* Make it faster

* fast

* Minor fixes in decoder

* Minor changes in ip parsing

* faster!

* bitAt

* 507k ops/s

* cleanup

* Cleanup file structure

* cleanup #2

* Lowercase files

* rename files

* going deeper

* Changing ip

* remove fn names

* stats notes

* remove sync suffix

* remove shit from index.js

* remove noise from decoder

* fastest

* cleanup

* remove unused var

* pointer experiment

* kinda works

* move metadata related code to metadata.js

* 0 and null

* Simplify 64 and 128 uints

* simplify bytes reading

* istanbul

* refactor small int + big int decoders

* add deps

* fix pre es6 syntax feature

* setup node version for travis

* fix tests under node 0.12

* legacy usage warning

* ip validator

* Allow cache configuration

* eslint

* fileStream => db

* move ip validation to ip.js

* istanbul config, better coverage

* update README.md

* remove unneeded dep

* error message for legacy database format
  • Loading branch information
runk committed May 24, 2016
1 parent 11e46fe commit e25bdb2
Show file tree
Hide file tree
Showing 69 changed files with 1,315 additions and 8,473 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -0,0 +1 @@
coverage
90 changes: 90 additions & 0 deletions .eslintrc
@@ -0,0 +1,90 @@
# borrowed from https://github.com/nodejs/node/blob/master/.eslintrc
env:
node: true
mocha: true

rules:
# Possible Errors
# http://eslint.org/docs/rules/#possible-errors
comma-dangle: [2, "only-multiline"]
no-control-regex: 2
no-debugger: 2
no-dupe-args: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-empty-character-class: 2
no-ex-assign: 2
no-extra-boolean-cast: 2
no-extra-parens: [2, "functions"]
no-extra-semi: 2
no-func-assign: 2
no-invalid-regexp: 2
no-irregular-whitespace: 2
no-negated-in-lhs: 2
no-obj-calls: 2
no-proto: 2
no-unexpected-multiline: 2
no-unreachable: 2
use-isnan: 2
valid-typeof: 2

# Best Practices
# http://eslint.org/docs/rules/#best-practices
no-fallthrough: 2
no-multi-spaces: 2
no-octal: 2
no-redeclare: 2
no-self-assign: 2
no-unused-labels: 2

# Strict Mode
# http://eslint.org/docs/rules/#strict-mode
strict: [2, "global"]

# Variables
# http://eslint.org/docs/rules/#variables
no-delete-var: 2
no-undef: 2
no-unused-vars: [2, {"args": "none"}]

# Node.js and CommonJS
# http://eslint.org/docs/rules/#nodejs-and-commonjs
no-mixed-requires: 2
no-new-require: 2
no-path-concat: 2
no-restricted-modules: [2, "sys", "_linklist"]

# Stylistic Issues
# http://eslint.org/docs/rules/#stylistic-issues
comma-spacing: 2
eol-last: 2
indent: [2, 2, {SwitchCase: 1}]
key-spacing: [2, {mode: "minimum"}]
keyword-spacing: 2
linebreak-style: [2, "unix"]
max-len: [2, 120, 2]
new-parens: 2
no-mixed-spaces-and-tabs: 2
no-multiple-empty-lines: [2, {max: 2}]
no-trailing-spaces: 2
quotes: [2, "single", "avoid-escape"]
semi: 2
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "never"]
space-in-parens: [2, "never"]
space-infix-ops: 2
space-unary-ops: 2

# ECMAScript 6
# http://eslint.org/docs/rules/#ecmascript-6
arrow-parens: [2, "always"]
arrow-spacing: [2, {"before": true, "after": true}]
constructor-super: 2
no-class-assign: 2
no-confusing-arrow: 2
no-const-assign: 2
no-dupe-class-members: 2
no-new-symbol: 2
no-this-before-super: 2
prefer-const: 2
template-curly-spacing: 2
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,5 +1,6 @@
test/dbs/full
benchmark/*.mmdb
testing.js
node_modules
.DS_Store
coverage
npm-debug.log
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "test/data"]
path = test/data
url = https://github.com/maxmind/MaxMind-DB.git
39 changes: 39 additions & 0 deletions .istanbul.yml
@@ -0,0 +1,39 @@
verbose: false
instrumentation:
root: .
extensions:
- .js
default-excludes: true
excludes: ["benchmark/*.js"]
embed-source: false
variable: __coverage__
compact: true
preserve-comments: true
complete-copy: false
save-baseline: false
baseline-file: ./coverage/coverage-baseline.json
include-all-sources: true
include-pid: false
es-modules: true
reporting:
print: summary
reports:
- lcov
dir: ./coverage
watermarks:
statements: [80, 95]
lines: [80, 95]
functions: [80, 95]
branches: [80, 95]
hooks:
hook-run-in-context: false
post-require-hook: null
handle-sigint: false

check:
global:
statements: 96
lines: 96
branches: 85
functions: 100
excludes: []
84 changes: 0 additions & 84 deletions .jshintrc

This file was deleted.

3 changes: 1 addition & 2 deletions .npmignore
@@ -1,4 +1,3 @@
test/dbs
benchmark/*.mmdb
coverage
testing.js
.DS_Store
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,4 +1,6 @@
language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"
- "4.4"
- "6.2"
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,14 @@

## Contributing

Make sure you run `npm i` command in the project's dir before you begin, it'll install all dev dependencies. Currently
code coverage is about **85%**, so new tests are essential when you add new functionality. There're several npm tasks
which you can find useful:

- `npm test` runs tests
- `npm run lint` runs js linter
- `npm run coverage` runs code coverage task and generates a report
- `npm run benchmark` runs performance benchmark

One pull request per one feature, nothing unusual.

2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Dmitry Shirokov
Copyright (c) 2016 Dmitry Shirokov

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
Expand Down

0 comments on commit e25bdb2

Please sign in to comment.