GithubHelp home page GithubHelp logo

chenglou / data-structures Goto Github PK

View Code? Open in Web Editor NEW
148.0 9.0 28.0 2.31 MB

Fast, light and hassle-free JavaScript data structures, written in CoffeeScript.

License: MIT License

CoffeeScript 50.00% JavaScript 50.00%

data-structures's Issues

Full rewrite in JS or not?

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.

Question: How to translate "require" statement into "import" statement

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:

1

import Map from 'data-structures';
then through the same new Map(); call,
then I would get a _dataStructures2.default is not a constructor error

2

import { Map } from 'data-structures';
then through same new Map(); call,
then I would get a _dataStructures.Map is not a constructor error

3

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:
screen shot 2017-06-13 at 5 38 41 pm

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!

Graph edgeSize is not always correct

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

Request: Interval tree

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

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.