Git Product home page Git Product logo

alphanumbers's Introduction

Build Status

alphanumbers

Converts numbers to alphabetical strings and back.

Because I don't like to use numbers in URL paths, this nodejs module converts them to an alphabetical string.

This is NOT a cryptographic module. Please don't use it as such.

Intended Use

This library is intended to convert numbers to characters and back for display only. Please use caution if storing the results as subsequent versions may change the character conversion sets.

Example

Converts 11121314 to HAQhW.

E.g.: http://example.com/users/11121314 becomes http://example.com/users/HAQhW

var alphanum = require('alphanumbers');

var str = alphanum.toAlpha(11121314);
//str = HAQhW

var num = alphanum.toNumeric('HAQhW');
//num = 11121314

Includes the replaceAll utility function as found on http://stackoverflow.com/a/6714233/153083 but doesn't add it as a prototype method.

replaceAll: function(sourceString, findStr, replaceWithStr, ignoreCase)

var str = alphanum.replaceAll('x','x','xyz',false); 
// str = xyz

Contribute

Fork and send pull request! Please observe the following:

  • Pure alphabetical substitution is preferred.
  • Any sort of statistical analysis for better number shorting much appreciated
  • Additional unit tests wanted

Currently 125 tests are passing.

http://semver.org/

alphanumbers's People

Contributors

agrothe avatar

Stargazers

 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.