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

h3-js

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h3-js - npm Package Compare versions

Comparing version 3.4.2 to 3.4.3

dist/browser/h3-js.es.js

10

benchmark/benchmarks.js
/*
* Copyright 2018 Uber Technologies, Inc.
* Copyright 2018-2019 Uber Technologies, Inc.
*

@@ -17,4 +17,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const Benchmark = require('benchmark');
const h3core = require('../lib/h3core');
import Benchmark from 'benchmark';
import * as h3core from '../lib/h3core';

@@ -33,3 +33,3 @@ // fixtures

module.exports = function makeBenchmarks() {
export default function makeBenchmarks() {
const suite = new Benchmark.Suite();

@@ -94,2 +94,2 @@

return suite;
};
}
/*
* Copyright 2018 Uber Technologies, Inc.
* Copyright 2018-2019 Uber Technologies, Inc.
*

@@ -19,4 +19,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const Benchmark = require('benchmark');
const makeBenchmarks = require('./benchmarks');
import Benchmark from 'benchmark';
import makeBenchmarks from './benchmarks';

@@ -23,0 +23,0 @@ window.Benchmark = Benchmark;

/*
* Copyright 2018 Uber Technologies, Inc.
* Copyright 2018-2019 Uber Technologies, Inc.
*

@@ -20,3 +20,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const makeBenchmarks = require('./benchmarks');
import makeBenchmarks from './benchmarks';

@@ -23,0 +23,0 @@ const suite = makeBenchmarks();

@@ -8,2 +8,8 @@ # Change Log

## [3.4.3] - 2019-04-01
### Added
- Changed module exports to ES6 syntax (#41)
- Added UMD bundle to published package (#41)
- Added separate bundles with an Emscripten browser-only build (#43)
## [3.4.2] - 2019-02-08

@@ -10,0 +16,0 @@ ### Fixed

@@ -77,14 +77,24 @@ # h3-js

To run the tests in both native ES6 (requires Node >= 6) and transpiled ES5:
To run the tests:
yarn test
Code must be formatted with `prettier`; unformatted code will fail the build. To format all files:
yarn prettier
### Benchmarks
The `h3-js` library includes a basic benchmark suite using [Benchmark.js](https://benchmarkjs.com/). Because many of the functions may be called over thousands of hexagons in a "hot loop", performance is an important concern. Benchmarks are run against the transpiled ES5 code by default. To run the benchmarks:
The `h3-js` library includes a basic benchmark suite using [Benchmark.js](https://benchmarkjs.com/). Because many of the functions may be called over thousands of hexagons in a "hot loop", performance is an important concern. Benchmarks are run against the transpiled ES5 code by default.
yarn run benchmarks
To run the benchmarks in Node:
Sample output (Macbook Pro running Node 6):
yarn benchmark-node
To run the benchmarks in a browser:
yarn benchmark-browser
Sample Node output (Macbook Pro running Node 6):
```

@@ -113,9 +123,7 @@ h3IsValid x 3,725,046 ops/sec ±0.47% (90 runs sampled)

yarn init-docker
yarn run build-emscripten
yarn docker-boot
yarn build-emscripten
The build script uses the `H3_VERSION` file to determine the version of the core library to build.
The build script uses the `H3_VERSION` file to determine the version of the core library to build. To use a different version of the library (e.g. to test local changes), clone the desired H3 repo to `./h3c` and then run `yarn docker-emscripten`.
NOTE: The current `h3-js` is built with `emscripten-1.37.40`. Earlier or later versions MAY NOT WORK (emscripten does not follow semver, so patch updates may include breaking changes).
## Contributing

@@ -122,0 +130,0 @@

/*
* Copyright 2018 Uber Technologies, Inc.
* Copyright 2018-2019 Uber Technologies, Inc.
*

@@ -4,0 +4,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

/*
* Copyright 2018 Uber Technologies, Inc.
* Copyright 2018-2019 Uber Technologies, Inc.
*

@@ -30,3 +30,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

// before new functions added here will be available.
module.exports = [
export default [
// The size functions are inserted via build/sizes.h

@@ -33,0 +33,0 @@ ['sizeOfH3Index', NUMBER],

/*
* Copyright 2018 Uber Technologies, Inc.
* Copyright 2018-2019 Uber Technologies, Inc.
*

@@ -21,4 +21,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const C = require('../out/libh3');
const BINDINGS = require('./bindings');
import C from '../out/libh3';
import BINDINGS from './bindings';

@@ -51,3 +51,3 @@ const H3 = {};

// Unit constants
const UNITS = {
export const UNITS = {
m: 'm',

@@ -257,10 +257,11 @@ km: 'km',

/**
* Store an H3 index in C memory.
* Store an H3 index in C memory. Primarily used as an efficient way to
* write sets of hexagons.
* @private
* @param {H3Index} h3Index H3 index to store
* @param {Number} cAddress Pointer to allocated C memory
* @param {Number} offset Offset, in number of H3 indexes, in case we're
* writing an array
* @param {Number} offset Offset, in number of H3 indexes from beginning
* of the current array
*/
function storeH3Index(h3Index, cAddress, offset = 0) {
function storeH3Index(h3Index, cAddress, offset) {
// HEAPU32 is a typed array projection on the index space

@@ -434,3 +435,3 @@ // as unsigned 32-bit integers. This means the index needs

*/
function h3IsValid(h3Index) {
export function h3IsValid(h3Index) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -446,3 +447,3 @@ return Boolean(H3.h3IsValid(lower, upper));

*/
function h3IsPentagon(h3Index) {
export function h3IsPentagon(h3Index) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -460,3 +461,3 @@ return Boolean(H3.h3IsPentagon(lower, upper));

*/
function h3IsResClassIII(h3Index) {
export function h3IsResClassIII(h3Index) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -472,3 +473,3 @@ return Boolean(H3.h3IsResClassIII(lower, upper));

*/
function h3GetBaseCell(h3Index) {
export function h3GetBaseCell(h3Index) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -484,3 +485,3 @@ return H3.h3GetBaseCell(lower, upper);

*/
function h3GetResolution(h3Index) {
export function h3GetResolution(h3Index) {
if (typeof h3Index !== 'string') {

@@ -500,3 +501,3 @@ return -1;

*/
function geoToH3(lat, lng, res) {
export function geoToH3(lat, lng, res) {
const latlng = C._malloc(SZ_GEOCOORD);

@@ -517,3 +518,3 @@ // Slightly more efficient way to set the memory

*/
function h3ToGeo(h3Index) {
export function h3ToGeo(h3Index) {
const latlng = C._malloc(SZ_GEOCOORD);

@@ -536,3 +537,3 @@ const [lower, upper] = h3IndexToSplitLong(h3Index);

*/
function h3ToGeoBoundary(h3Index, formatAsGeoJson) {
export function h3ToGeoBoundary(h3Index, formatAsGeoJson) {
const geoBoundary = C._malloc(SZ_GEOBOUNDARY);

@@ -556,3 +557,3 @@ const [lower, upper] = h3IndexToSplitLong(h3Index);

*/
function h3ToParent(h3Index, res) {
export function h3ToParent(h3Index, res) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -569,3 +570,3 @@ return readH3Index(H3.h3ToParent(lower, upper, res));

*/
function h3ToChildren(h3Index, res) {
export function h3ToChildren(h3Index, res) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -587,3 +588,3 @@ const maxCount = H3.maxH3ToChildrenSize(lower, upper, res);

*/
function kRing(h3Index, ringSize) {
export function kRing(h3Index, ringSize) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -606,3 +607,3 @@ const maxCount = H3.maxKringSize(ringSize);

*/
function kRingDistances(h3Index, ringSize) {
export function kRingDistances(h3Index, ringSize) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -641,3 +642,3 @@ const maxCount = H3.maxKringSize(ringSize);

*/
function hexRing(h3Index, ringSize) {
export function hexRing(h3Index, ringSize) {
const maxCount = ringSize === 0 ? 1 : 6 * ringSize;

@@ -668,3 +669,3 @@ const hexagons = C._calloc(maxCount, SZ_H3INDEX);

*/
function polyfill(coordinates, res, isGeoJson) {
export function polyfill(coordinates, res, isGeoJson) {
validateRes(res);

@@ -701,3 +702,3 @@ isGeoJson = Boolean(isGeoJson);

*/
function h3SetToMultiPolygon(h3Indexes, formatAsGeoJson) {
export function h3SetToMultiPolygon(h3Indexes, formatAsGeoJson) {
// Early exit on empty input

@@ -733,3 +734,3 @@ if (!h3Indexes || !h3Indexes.length) {

*/
function compact(h3Set) {
export function compact(h3Set) {
if (!h3Set || !h3Set.length) {

@@ -764,3 +765,3 @@ return [];

*/
function uncompact(compactedSet, res) {
export function uncompact(compactedSet, res) {
validateRes(res);

@@ -800,3 +801,3 @@ if (!compactedSet || !compactedSet.length) {

*/
function h3IndexesAreNeighbors(origin, destination) {
export function h3IndexesAreNeighbors(origin, destination) {
const [oLower, oUpper] = h3IndexToSplitLong(origin);

@@ -814,3 +815,3 @@ const [dLower, dUpper] = h3IndexToSplitLong(destination);

*/
function getH3UnidirectionalEdge(origin, destination) {
export function getH3UnidirectionalEdge(origin, destination) {
const [oLower, oUpper] = h3IndexToSplitLong(origin);

@@ -827,3 +828,3 @@ const [dLower, dUpper] = h3IndexToSplitLong(destination);

*/
function getOriginH3IndexFromUnidirectionalEdge(edgeIndex) {
export function getOriginH3IndexFromUnidirectionalEdge(edgeIndex) {
const [lower, upper] = h3IndexToSplitLong(edgeIndex);

@@ -839,3 +840,3 @@ return readH3Index(H3.getOriginH3IndexFromUnidirectionalEdge(lower, upper));

*/
function getDestinationH3IndexFromUnidirectionalEdge(edgeIndex) {
export function getDestinationH3IndexFromUnidirectionalEdge(edgeIndex) {
const [lower, upper] = h3IndexToSplitLong(edgeIndex);

@@ -851,3 +852,3 @@ return readH3Index(H3.getDestinationH3IndexFromUnidirectionalEdge(lower, upper));

*/
function h3UnidirectionalEdgeIsValid(edgeIndex) {
export function h3UnidirectionalEdgeIsValid(edgeIndex) {
const [lower, upper] = h3IndexToSplitLong(edgeIndex);

@@ -863,3 +864,3 @@ return Boolean(H3.h3UnidirectionalEdgeIsValid(lower, upper));

*/
function getH3IndexesFromUnidirectionalEdge(edgeIndex) {
export function getH3IndexesFromUnidirectionalEdge(edgeIndex) {
const [lower, upper] = h3IndexToSplitLong(edgeIndex);

@@ -881,3 +882,3 @@ const count = 2;

*/
function getH3UnidirectionalEdgesFromHexagon(h3Index) {
export function getH3UnidirectionalEdgesFromHexagon(h3Index) {
const [lower, upper] = h3IndexToSplitLong(h3Index);

@@ -900,3 +901,3 @@ const count = 6;

*/
function getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson) {
export function getH3UnidirectionalEdgeBoundary(edgeIndex, formatAsGeoJson) {
const geoBoundary = C._malloc(SZ_GEOBOUNDARY);

@@ -920,3 +921,3 @@ const [lower, upper] = h3IndexToSplitLong(edgeIndex);

*/
function h3Distance(origin, destination) {
export function h3Distance(origin, destination) {
const [oLower, oUpper] = h3IndexToSplitLong(origin);

@@ -949,3 +950,3 @@ const [dLower, dUpper] = h3IndexToSplitLong(destination);

*/
function h3Line(origin, destination) {
export function h3Line(origin, destination) {
const [oLower, oUpper] = h3IndexToSplitLong(origin);

@@ -983,3 +984,3 @@ const [dLower, dUpper] = h3IndexToSplitLong(destination);

*/
function experimentalH3ToLocalIj(origin, destination) {
export function experimentalH3ToLocalIj(origin, destination) {
const ij = C._malloc(SZ_COORDIJ);

@@ -1030,3 +1031,3 @@ const retVal = H3.experimentalH3ToLocalIj(

*/
function experimentalLocalIjToH3(origin, coords) {
export function experimentalLocalIjToH3(origin, coords) {
// Validate input coords

@@ -1065,3 +1066,3 @@ if (!coords || typeof coords.i !== 'number' || typeof coords.j !== 'number') {

*/
function hexArea(res, unit) {
export function hexArea(res, unit) {
validateRes(res);

@@ -1086,3 +1087,3 @@ switch (unit) {

*/
function edgeLength(res, unit) {
export function edgeLength(res, unit) {
validateRes(res);

@@ -1107,3 +1108,3 @@ switch (unit) {

*/
function numHexagons(res) {
export function numHexagons(res) {
validateRes(res);

@@ -1127,3 +1128,3 @@ // Get number as a long value

*/
function getRes0Indexes() {
export function getRes0Indexes() {
const count = H3.res0IndexCount();

@@ -1143,3 +1144,3 @@ const hexagons = C._malloc(SZ_H3INDEX * count);

*/
function degsToRads(deg) {
export function degsToRads(deg) {
return (deg * Math.PI) / 180;

@@ -1154,46 +1155,4 @@ }

*/
function radsToDegs(rad) {
export function radsToDegs(rad) {
return (rad * 180) / Math.PI;
}
// ----------------------------------------------------------------------------
// Export
module.exports = {
h3IsValid,
h3IsPentagon,
h3IsResClassIII,
h3GetBaseCell,
h3GetResolution,
geoToH3,
h3ToGeo,
h3ToGeoBoundary,
h3ToParent,
h3ToChildren,
kRing,
kRingDistances,
hexRing,
polyfill,
h3SetToMultiPolygon,
compact,
uncompact,
h3IndexesAreNeighbors,
getH3UnidirectionalEdge,
getOriginH3IndexFromUnidirectionalEdge,
getDestinationH3IndexFromUnidirectionalEdge,
h3UnidirectionalEdgeIsValid,
getH3IndexesFromUnidirectionalEdge,
getH3UnidirectionalEdgesFromHexagon,
getH3UnidirectionalEdgeBoundary,
h3Distance,
h3Line,
experimentalH3ToLocalIj,
experimentalLocalIjToH3,
hexArea,
edgeLength,
numHexagons,
getRes0Indexes,
degsToRads,
radsToDegs,
UNITS
};
{
"name": "h3-js",
"version": "3.4.2",
"version": "3.4.3",
"description": "Emscripten transpiled libh3 'bindings' for Node/Web JS",

@@ -21,30 +21,48 @@ "author": "David Ellis <isv.damocles@gmail.com>",

],
"main": "index.js",
"es2015": "lib/h3core.js",
"main": "dist/h3-js.js",
"umd:main": "dist/h3-js.umd.js",
"unpkg": "dist/h3-js.umd.js",
"module": "dist/h3-js.es.js",
"es2015": "dist/h3-js.es.js",
"source": "lib/h3core.js",
"scripts": {
"lint": "eslint lib* test/*",
"test": "yarn dist-test && yarn lint && yarn test-es6 && yarn test-dist && yarn test-parity",
"test-raw": "node test/index.js",
"test-es6": "yarn test-raw | faucet",
"test-parity": "node test/test-parity.js | faucet",
"test-dist": "node dist/test/index.js | faucet",
"cover": "istanbul cover -x out/*.js -- test/index.js",
"view-cover": "istanbul cover -x out/*.js --report=html -- test/index.js && open coverage/index.html",
"build-update-h3": "bash scripts/update-h3.sh",
"build-emscripten": "yarn build-update-h3 && yarn docker-emscripten",
"build-docs": "jsdoc2md --global-index-format grouped --partial doc-files/scope.hbs --helper ./doc-files/insert-version.js --separators --template doc-files/README.tmpl.md lib/h3core.js > README.md",
"bundle-umd": "microbundle --name h3 --format=umd",
"bundle-cjs": "microbundle --format=cjs --no-compress",
"bundle-es": "microbundle --format=es --no-compress",
"bundle-cjs-browser": "microbundle -o dist/browser --format=cjs --no-compress --alias ../out/libh3=$(printf '%q' \"$PWD\")/dist/libh3-browser",
"bundle-es-browser": "microbundle -o dist/browser --format=es --no-compress --alias ../out/libh3=$(printf '%q' \"$PWD\")/dist/libh3-browser",
"dist": "yarn dist-clean && yarn docker-emscripten-browser && yarn bundle-umd && yarn bundle-cjs && yarn bundle-cjs-browser && yarn bundle-es && yarn bundle-es-browser",
"dist-clean": "rm -rf dist",
"rollup-test": "rollup test/index.js --file dist/test.js --sourcemap --format=cjs --external=tape,fs,path",
"rollup-bindings": "rollup build/print-bindings.js --file dist/print-bindings.js --format cjs",
"rollup-benchmark-browser": "rollup benchmark/browser.js --file dist/benchmark.browser.js --format=umd --external=benchmark",
"rollup-benchmark-node": "rollup benchmark/node.js --file dist/benchmark.node.js --format=cjs --external=benchmark",
"docker-boot": "docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-tag-1.38.29-64bit bash",
"docker-reboot": "docker stop emscripten && docker rm emscripten && yarn docker-boot",
"docker-emscripten": "yarn docker-emscripten-umd",
"docker-emscripten-run": "yarn rollup-bindings && docker exec -it emscripten bash scripts/update-emscripten.sh",
"docker-emscripten-umd": "yarn docker-emscripten-run -o libh3.js",
"docker-emscripten-browser": "yarn docker-emscripten-run -s ENVIRONMENT=web -o libh3-browser.js && mv out/libh3-browser.js dist",
"check-prettier": "yarn prettier && git diff --exit-code",
"check-docs": "yarn build-docs && git diff --exit-code",
"dist": "yarn dist-clean && mkdir -p dist/out && buble -i lib -o dist/lib && cp out/libh3.js dist/out",
"dist-clean": "rm -rf dist",
"dist-test": "yarn dist && buble -i test -o dist/test",
"dist-benchmark": "yarn dist && buble -i benchmark -o dist/benchmark",
"benchmark-node": "yarn dist-benchmark && node dist/benchmark/node.js",
"benchmark-browser": "yarn dist-benchmark && budo dist/benchmark/browser.js -t babelify --open --title 'h3-js benchmarks'",
"prepublish": "yarn dist",
"init-docker": "docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-tag-1.38.25-64bit bash",
"build-emscripten": "docker exec -it emscripten bash .build-emscripten.sh",
"build-docs": "jsdoc2md --global-index-format grouped --partial doc-files/scope.hbs --helper ./doc-files/insert-version.js --separators --template doc-files/README.tmpl.md lib/h3core.js > README.md",
"lint": "eslint lib* test/*",
"test": "yarn lint && yarn test-fast",
"test-fast": "yarn test-raw | faucet",
"test-raw": "yarn rollup-test && node dist/test.js",
"cover": "yarn rollup-test && nyc --clean node dist/test.js",
"cover-view": "yarn rollup-test && nyc --clean --reporter=html node dist/test.js && open coverage/index.html",
"benchmark-node": "yarn rollup-benchmark-node && node dist/benchmark.node.js",
"benchmark-browser": "yarn rollup-benchmark-browser && budo dist/benchmark.browser.js --open --title 'h3-js benchmarks'",
"prepublishOnly": "yarn dist",
"prettier": "prettier --write --single-quote --no-bracket-spacing --print-width=100 'lib/**/*.js' 'build/**/*.js' 'test/**/*.js'"
},
"browser": {
"./dist/h3-js.js": "./dist/browser/h3-js.js",
"./dist/h3-js.es.js": "./dist/browser/h3-js.es.js"
},
"devDependencies": {
"benchmark": "^2.1.4",
"buble": "^0.19.3",
"budo": "^11.5.0",

@@ -56,5 +74,7 @@ "eslint": "^4.19.1",

"faucet": "0.0.1",
"istanbul": "^0.4.3",
"jsdoc-to-markdown": "^4.0.1",
"microbundle": "^0.11.0",
"nyc": "git://github.com/istanbuljs/nyc#1f6c3d4a2bd74e3fada35eb029ec9fb6b480e99e",
"prettier": "^1.12.1",
"rollup": "^1.7.0",
"tape": "^4.8.0"

@@ -67,3 +87,9 @@ },

},
"nyc": {
"exclude": [
"**/out/**",
"**/test/**"
]
},
"dependencies": {}
}

@@ -712,14 +712,24 @@ # h3-js

To run the tests in both native ES6 (requires Node >= 6) and transpiled ES5:
To run the tests:
yarn test
Code must be formatted with `prettier`; unformatted code will fail the build. To format all files:
yarn prettier
### Benchmarks
The `h3-js` library includes a basic benchmark suite using [Benchmark.js](https://benchmarkjs.com/). Because many of the functions may be called over thousands of hexagons in a "hot loop", performance is an important concern. Benchmarks are run against the transpiled ES5 code by default. To run the benchmarks:
The `h3-js` library includes a basic benchmark suite using [Benchmark.js](https://benchmarkjs.com/). Because many of the functions may be called over thousands of hexagons in a "hot loop", performance is an important concern. Benchmarks are run against the transpiled ES5 code by default.
yarn run benchmarks
To run the benchmarks in Node:
Sample output (Macbook Pro running Node 6):
yarn benchmark-node
To run the benchmarks in a browser:
yarn benchmark-browser
Sample Node output (Macbook Pro running Node 6):
```

@@ -748,9 +758,7 @@ h3IsValid x 3,725,046 ops/sec ±0.47% (90 runs sampled)

yarn init-docker
yarn run build-emscripten
yarn docker-boot
yarn build-emscripten
The build script uses the `H3_VERSION` file to determine the version of the core library to build.
The build script uses the `H3_VERSION` file to determine the version of the core library to build. To use a different version of the library (e.g. to test local changes), clone the desired H3 repo to `./h3c` and then run `yarn docker-emscripten`.
NOTE: The current `h3-js` is built with `emscripten-1.37.40`. Earlier or later versions MAY NOT WORK (emscripten does not follow semver, so patch updates may include breaking changes).
## Contributing

@@ -757,0 +765,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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