Giter VIP home page Giter VIP logo

lmammino / indexed-string-variation Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 4.0 54 KB

Experimental JavaScript module to generate all possible variations of strings over an alphabet using an n-ary virtual tree

Home Page: http://loige.co

License: MIT License

JavaScript 100.00%
alphabet tree algorithm virtual characters nodejs node library variations duplicates strings string javascript javascript-library

indexed-string-variation's Issues

Extend README

  • Describe virtual tree approach.
  • Add section about how to install from NPM

Bug with alphabet filter to remove duplicates when using default alphabet

var isv = require('indexed-string-variation').default;

var i = 351132634265345217312;
console.log(i);
console.log(isv()(i));

output

351132634265345200000
C:\Users\Luciano.Mammino\test\node_modules\indexed-string-variation\lib\index.js:10
    return alphabet.split('').filter(function (item, pos, self) {
                   ^

TypeError: Cannot read property 'split' of undefined
    at cleanAlphabet (C:\Users\Luciano.Mammino\test\node_modules\indexed-string-variation\lib\index.js:10:20)
    at isv (C:\Users\Luciano.Mammino\test\node_modules\indexed-string-variation\lib\index.js:19:14)
    at Object.<anonymous> (C:\Users\Luciano.Mammino\test\test.js:5:13)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:138:18)
    at node.js:974:3

Bug when using big indexes

Sample code:

var isv = require('indexed-string-variation').default;

var i = 3511326342653452173122134435345;
console.log(i);
console.log(isv('ab')(i));

output:

3.511326342653452e+30
C:\Users\Luciano.Mammino\test\node_modules\indexed-string-variation\lib\index.js:38
      throw new TypeError('index must be a non-negative integer');
      ^

TypeError: index must be a non-negative integer
    at C:\Users\Luciano.Mammino\test\node_modules\indexed-string-variation\lib\index.js:38:13
    at Object.<anonymous> (C:\Users\Luciano.Mammino\test\test.js:5:22)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:138:18)
    at node.js:974:3

Improve exported modules

  • Expose defaultAlphabet in the module
  • Export the default function as both default and generator
  • Update tests
  • Update documentation

Validate input

  • Validate input alphabet (must be string)
  • Validate index (must be 0 or positive integer)
  • Update tests to provide cover check for errors

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.