chenglou / data-structures Goto Github PK
View Code? Open in Web Editor NEWFast, light and hassle-free JavaScript data structures, written in CoffeeScript.
License: MIT License
Fast, light and hassle-free JavaScript data structures, written in CoffeeScript.
License: MIT License
Will leave this issue open for library users.
Kind of a sensational title, since it'd mostly just be taking the compiled js and format it a bit. But this might help adoption.
Hi, I am trying to use the Map
class in an ES6 project and I am running into some problem with importing the Map
class.
ES5
In the ES5 version of my code I was able to require
the class by calling the following:
var Map = require('data-structures').Map; //data-structures was installed by npm
then I was able to initiate and then use the class by calling new Map();
ES6
Now when I try to convert the code above to an import
statement, I tried the following:
import Map from 'data-structures';
then through the same new Map();
call,
then I would get a _dataStructures2.default is not a constructor
error
import { Map } from 'data-structures';
then through same new Map();
call,
then I would get a _dataStructures.Map is not a constructor
error
import * as dataStructures from 'data-structures';
then I call this.myMap = dataStructures.Map;
but this.myMap will be undefined and my dataStructures looks like this:
I can't figure out a way to translate the require().Map statement into an import statement. Someone has run into a similar problem, but since the export statement of the Map class is different from what is described in the solution, I was not able to use it in my code.
Any help/advice on how I can translate the require into import will be appreciated!
I think there is a Bug by decreasing edgeSize after removing multiple nodes at the same time. edgeCount of nodes has incorrect value after deleting a neighbor node.
The following test fails:
describe "Another tricky test -- ",->
it "edgeSize after adding and removing nodes",->
graph = new Graph();
expect(graph.addNode "1").toBeDefined()
expect(graph.addNode "2").toBeDefined()
expect(graph.addNode "3").toBeDefined()
expect(graph.addNode "4").toBeDefined()
expect(graph.addNode "5").toBeDefined()
expect(graph.addEdge "1", "2").toBeDefined()
expect(graph.addEdge "2", "4").toBeDefined()
expect(graph.addEdge "2", "3").toBeDefined()
expect(graph.addEdge "2", "5").toBeDefined()
expect(graph.addEdge "5", "4").toBeDefined()
expect(graph.addEdge "1", "3").toBeDefined()
###
1 -> 2 -> 4
\ | \ ^
\ | \ |
˅ ˅ ˅ |
3 5
###
expect(graph.removeNode "2").toBeDefined()
expect(graph.removeNode "1").toBeDefined()
###
4
^
|
|
3 5
###
expect(graph.edgeSize).toBe 1 ## Bug edgeSize = 0
expect(graph.nodeSize).toBe 3
Including coffee-script as dependency adds serious bulk when using some package managers.
You should compile before publishing. Example:
https://github.com/aldonline/notifying.js
Hey there,
I'd love to see an easy to use interval tree for javascript as there don't seem to be any out there currently that are working/supported.
Perhaps https://github.com/shinout/interval-tree2 could be used as a starting point, seeing how it's written in coffeescript.
Thanks so much!
Thomas
As the title says.
I would love to see a Priority Queue too! :)
See http://rosettacode.org/wiki/Priority_queue#CoffeeScript
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.