Coder Social home page Coder Social logo

es6-native-map's Introduction

es6-native-map

==============

This Node.js module provides an interface to a native hashmap data structure with the ES6 Map api. This is significantly faster than the built-in Map, but loses the order of key/value inserts.

As of 2.0.0, es6-native-map requires node.js 0.12 or later. If you are running node.js 0.10, stick with the 1.x.x line.

As of 4.0.0, es6-native-map actually implements @@iterator correctly, so you can use all the iterable functions and operators.

To install, simply:

npm install es6-native-map

To use:

var Map = require('es6-native-map');

var map = new Map();
map.set('key', {value: 'value'});
map.set('something', 'else');

console.log('There are', map.size, 'item(s) in the map');

iterator = map.entries();
item = iterator.next();
while (!item.done) {
    console.log(item.value[0], '=', item.value[1]);
    item = iterator.next();
}

See the official ES6 Map documentation

This package is made possible because of Grokker, one of the best places to work. If you are a JS developer looking for a new gig, send me an email at ['chad', String.fromCharCode(64), 'grokker', String.fromCharCode(0x2e), 'com'].join('').

es6-native-map's People

Contributors

chad3814 avatar sariag avatar vincentguinaudeau avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

es6-native-map's Issues

when i install use `npm install ex6-native-map --save`, i get an error. so i decide not ues this lib.

gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: node-v0.12.1.tar.gz local checksum 8ac59eea6f135c661cab8b054ca5f014452ba200343a0e9ca95e7d432a300b4d not match remote 30693376519c9736bcb22d44513252aee1d9463d78ac6c744ecb6d13fd91d680
gyp ERR! stack at deref (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:299:20)
gyp ERR! stack at IncomingMessage. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:340:13)
gyp ERR! stack at IncomingMessage.emit (events.js:129:20)
gyp ERR! stack at _stream_readable.js:908:16
gyp ERR! stack at process._tickCallback (node.js:355:11)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/tong/work/code/qserver/node_modules/es6-native-map
gyp ERR! node -v v0.12.1
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "es6-native-map" "--save"
npm ERR! node v0.12.1
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp configure build'.
npm ERR! This is most likely a problem with the es6-native-map package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls es6-native-map
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/tong/work/code/qserver/npm-debug.log

segfault when delete, set or clear

hello, it's me again.

This time it's the clear, delete and set fonctions who cause trouble.

the problem seem to come from this code, present on all three fonction :

from map.cpp

itr->first->Reset();
itr->second->Reset();

delete itr->first;
delete itr->second;

I've workauround this by commenting both line where itr->first is involve, but I'm absolutly not sure this is a good correction.

Missing spread operator support in [email protected]

The spread operator ... works fine on the ES6 Map object, but generates an error on [email protected]:

const Map = require('es6-native-map');
var m = new Map();
m.set('key1', 123); m.set('key2', 345); m.set('key3', 234);
console.log( 'Sorted Map:', [... m].sort((a,b)=>a[1]-b[1]) );

results in >> TypeError: undefined is not a function
while it should output >> Sorted Map: [ [ 'key1', 123 ], [ 'key3', 234 ], [ 'key2', 345 ] ]

Out of memory on huge load

hello,

I use this module for what you say it's does : workaround the V8 memory limit. But when i use it for some huge caching, i end up with a out of memory, desipite i have several Go left on RAM.

So i start looking thinking it was a bug from my project, but it seem your modules don't completely free V8 memory.

To test this, you can run your stressor test (without forcing gc) with the --trace-gc option. Then you see, cycle by cycle, the memory space of v8 slowly increase (i use to store very long string on your map, and the difference between global nodeJs memory and V8 internal memory is lesser here).

It will awesome if you can solve this issues because your two module (hashtable and es6-native-map) are the only two who can't expend v8 memory as far as i kwon.

gyp/VS2013 (12.0) is failing to build on Win7x64

..\src\map.cpp(60): error C2466: cannot allocate an array of constant size 0 [C
:\code\node_modules\es6-native-map\build\native.vcxproj]
..\src\map.cpp(60): error C2133: 'empty_args' : unknown size [C:\code\node_modu
les\es6-native-map\build\native.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe fail
ed with exit code: 1

get and has methods don't work

With the last version of the module (3.0), the get and has fonction always behave as if the keys don't exist, even with this simple script (tested on windows and linux with nodeJs 4.1.2) :

var es6Map = require('es6-native-map');

var table = new es6Map()

table.set("foo", "bar")
console.log(table.get("foo"), table.has("foo")) // undefined false

However, the other fonction like forEach, entries, keys and values still return values.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.