Giter VIP home page Giter VIP logo

sorted-array's Introduction

Hi ๐Ÿ‘‹, I'm Aadit M Shah

A passionate open-source developer from India

aaditmshah

aaditmshah

  • ๐Ÿ”ญ Iโ€™m currently working on Typecraft and Ivory ESLint Config

  • ๐ŸŒฑ Iโ€™m currently learning ESLint, Tailwind, and Next.js

  • ๐Ÿ“ I regularly write articles on https://aadit.codes/blog/page/1

  • ๐Ÿ’ฌ Ask me about Functional Programming, JavaScript, TypeScript, and Haskell

  • ๐Ÿ“ซ How to reach me [email protected]

  • โšก Fun fact I love playing Chess and OSRS.

Connect with me:

zcombinator aaditmshah 783743

Languages and Tools:

bash c css3 git haskell html5 javascript jest linux nextjs nodejs react tailwind typescript

Support:

aaditmshah aaditmshah



Stats:

aaditmshah

ย aaditmshah

aaditmshah

sorted-array's People

Contributors

leocda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sorted-array's Issues

this.insert is not a function

This works as expected in a fresh empty project, but when trying to use it from an existing project I get an error on the require() line

const SortedArray = require('sorted-array');

Uncaught TypeError: this.insert is not a function
at Object.constructor (sorted-array.js?c258:9)

In Chrome I can see that when we reach line 9 'this' exists but only has 'array' and 'compare' in it, not 'insert'. (Its proto doesn't have 'insert' either).

I haven't been able to figure out what's happening. Why is require() executing a constructor (seems to happen at "module.exports = SortedArray" on line 74)? Is there a webpack/Babel setting I'm missing? Some new Javascript keyword?

Doesn't work using compare function

This doesn't work when using a compare function? E.g.

var SortedArray = require("sorted-array");
var sorted = new SortedArray([{a:112}, {a: 99}, {a:4}], (a, b) => a.a - a.a);
console.log(sorted.array); // [ { a: 112 }, { a: 4 }, { a: 99 } ]

Constructor use does not match example

sorted-array.js line 6 states that var length = arguments.length;. However, to work as it does in the example, it needs to be array.length. Otherwise, it will only copy the first element into the internal array (or the first two if a compare function is supplied).

Should `remove()` use `indexOf()` instead of `search`?

Is there any benefit to using this.search(element) instead of this.array.indexOf(element)?

If this.compare uses a nested property of element, there could be false positives.

I assumed remove() would simply remove element from this.array.

remove: function (element) {
  var index = this.array.indexOf(element);
  if (index >= 0) this.array.splice(index, 1);
  return this;
}

Oh, and thanks for making this library! ๐Ÿป

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.