Skip to content

Make rbush an ES6 library #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ npm-debug.log
coverage
rbush.js
rbush.min.js
rbush.es.js
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

4 changes: 1 addition & 3 deletions bench/perf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
import rbush from '..';

var N = 1000000,
maxFill = 16;
Expand Down Expand Up @@ -31,8 +31,6 @@ var bboxes100 = genData(1000, 100 * Math.sqrt(0.1));
var bboxes10 = genData(1000, 10);
var bboxes1 = genData(1000, 1);

var rbush = typeof require !== 'undefined' ? require('..') : rbush;

var tree = rbush(maxFill);

console.time('insert one by one');
Expand Down
9 changes: 2 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
'use strict';
import quickselect from 'quickselect';

module.exports = rbush;
module.exports.default = rbush;

var quickselect = require('quickselect');

function rbush(maxEntries, format) {
export default function rbush(maxEntries, format) {
if (!(this instanceof rbush)) return new rbush(maxEntries, format);

// max entries in a node is 9 by default; min node fill is 40% for best performance
Expand Down
31 changes: 19 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,45 @@
"author": "Vladimir Agafonkin",
"license": "MIT",
"main": "index.js",
"module": "index.js",
"browser": "rbush.js",
"jsdelivr": "rbush.js",
"unpkg": "rbush.js",
"devDependencies": {
"benchmark": "^2.1.4",
"browserify": "^14.5.0",
"eslint": "^4.13.1",
"eslint-config-mourner": "^2.0.3",
"esm": "^3.0.84",
"faucet": "0.0.1",
"istanbul": "~0.4.5",
"tape": "^4.8.0",
"uglify-js": "^3.2.2"
"nyc": "^13.1.0",
"rollup": "^0.67.3",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-uglify": "^6.0.0",
"tape": "^4.8.0"
},
"scripts": {
"test": "eslint index.js test/test.js && node test/test.js | faucet",
"perf": "node ./bench/perf.js",
"cov": "istanbul cover test/test.js -x test/test.js",
"build": "browserify index.js -s rbush -o rbush.js",
"build-min": "browserify index.js -s rbush | uglifyjs -c warnings=false -m > rbush.min.js",
"prepare": "npm run build && npm run build-min"
"test": "eslint index.js test/test.js && node -r esm test/test.js | faucet",
"perf": "node -r esm ./bench/perf.js",
"cov": "nyc --check-coverage --require esm npm test",
"build": "rollup -c",
"prepare": "npm run build"
},
"files": [
"rbush.js",
"rbush.min.js"
"rbush.min.js",
"rbush.es.js"
],
"eslintConfig": {
"extends": "mourner",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"new-cap": 0,
"consistent-return": 0
}
},
"dependencies": {
"quickselect": "^1.0.1"
"quickselect": "^2.0.0"
}
}
25 changes: 25 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {uglify} from 'rollup-plugin-uglify';
import resolve from 'rollup-plugin-node-resolve';

export default [{
input: 'index.js',
output: [{
name: 'rbush',
format: 'umd',
file: 'rbush.js',
indent: false
}, {
file: 'rbush.es.js',
format: 'es'
}],
plugins: [resolve()]
},
{
input: 'index.js',
output: {
name: 'rbush',
format: 'umd',
file: 'rbush.min.js',
},
plugins: [resolve(), uglify()]
}];
5 changes: 2 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

/*eslint key-spacing: 0, comma-spacing: 0 */

var rbush = require('..'),
t = require('tape');
import rbush from '..';
import t from 'tape';

function sortedEqual(t, a, b, compare) {
compare = compare || defaultCompare;
Expand Down