Coder Social home page Coder Social logo

range-list's Introduction

range-list

Introduction

A lib for managing range list.

  • range: a pair of integers (other type would initiate errors): such as [2, 6), this range inclouds integers: 2, 3, 4, and 5.
  • range list
    • ordered: from samll to large: such as [10, 20) [6, 9) is not right, the right order is [6, 9) [10, 20)
    • not overlapped: such as [2, 10) [5, 20) is not right, the right list is [2, 5) [10, 20)

Development

  • developed with typescript.
  • use babel to support es6 develop environment.
  • use ts-jest to test.
  • also support script in package.json to help develop and test.

How to use

  • not pulished yet.
  • already published by npm
> npm install neo-range-list
import { MyRangeList } from 'neo-range-list';

const rl = new MyRangeList();
rl.add([1, 5]);
rl.print();
// Should display: [1, 5)
rl.add([10, 20]);
rl.print();
// Should display: [1, 5) [10, 20)
rl.add([20, 20]);
rl.print();
// Should display: [1, 5) [10, 20)
rl.add([20, 21]);
rl.print();
// Should display: [1, 5) [10, 21)
rl.add([2, 4]);
rl.print();
// Should display: [1, 5) [10, 21)
rl.add([3, 8]);
rl.print();
// Should display: [1, 8) [10, 21)
rl.remove([10, 10]);
rl.print();
// Should display: [1, 8) [10, 21)
rl.remove([10, 11]);
rl.print();
// Should display: [1, 8) [11, 21)
rl.remove([15, 17]);
rl.print();
// Should display: [1, 8) [11, 15) [17, 21)
rl.remove([3, 19]);
rl.print();
// Should display: [1, 3) [19, 21)

Works not finished

  • form now on, integer is only validated, if users who use pairs of decimal as a range, may initiate unkown error
  • not so sure the efficiency of large size of range list refactored
  • some code need to be refactored

Thanks

  • firstly, thanks to jerry.ai that I got a opportunity to write this project.
  • secondly, thanks Jayden Li, that I found a npm package: j-range-list-js published by him witch inspired me from several aspects.

range-list's People

Contributors

fengyingdian avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

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.