GithubHelp home page GithubHelp logo

siuying / between Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dominictarr/between

0.0 2.0 0.0 138 KB

generate arbitary strings that sort between two strings

License: MIT License

JavaScript 100.00%

between's Introduction

between

generate a string that is between two strings.

Example

there is an infinite number of numbers between 0 and 1. 0.5, 0.25, 0.00000000000000000000001, etc.

I wrote this module because I needed it for crdt.

I used it to mark the position of items in a sequence.

Say, A, B, C are inserted into positions 1, 2, 3.
then, insert D inbetween A & B, into position 1.5. then move C to position 1.25 and B to position 1.125. Now the list is A, B, C, D.

Seems like a funny way to track the position of elements right?

This method has a very important property: it is commutative. concurrent inserts behave nicely, because inserting between two items does not change the positions of nodes later in the list!

API

between(a, b)

var b  = require('between')
var tween = b.between('a', 'b')

//tween is a string that will sort between 'a' and 'b'.

a and b can be any string that does not end in the lowest character. this is like how there is only one number between 0 and 1 that ends in a "0".

between.hi, between.lo

the top most string possible, and the lowest string possible. You must not be used as positions for items, because it will not be possible to insert items after or before them. These values represent the space infront of the first item, and the space between the last item.

cool links

between has been ported to Objective-C

License

MIT

between's People

Contributors

dominictarr avatar

Watchers

 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.