Nanananananananana.. Pat Man!
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    tweet-packerpublic

    tweet-packer

    NPM Build Status js-standard-style

    given an array of strings, tweet-packer will return a new array with those strings compacted to all be as close to 140 chars as possible (or whatever number you pass). I use this to compress tweets emitted by The Botgle Beat, which is an internet newspaper about games of boggle played over twitter.

    API

    tweetPacker(arrayOfLines, maxLength:optional, separator:optional)

    • arrayOfLines: smaller lines will be optimally joined together with the separator such that they are all less than the maxLength
    • maxLength: defaults to 140, the max length that a line can be.
    • separator: defaults to " ", perhaps "\n" is more your style? Or instead, mayhaps you prefer " : "? Have at it!

    EXAMPLE

    var tweetPacker = require('tweet-packer')
     
    // GIVEN: 100 a's, 40 b's, and 30 c's
    tweetPacker(["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccc"])
     
    // it tries to maximize space by combining the a's and the b's
    => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccc"]

    install

    npm i tweet-packer

    Downloadslast 7 days

    2

    version

    1.0.2

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar