Nautical Poseidon Mythology

    useful-ut

    1.0.2 • Public • Published

    Installation

    npm i useful-ut
    

    Import

    let ut = require('useful-ut')
    

    Usage

    ut.String

    digits: '01234567890'
    specials: '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
    ascii_letters: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    ascii_lowercase: 'abcdefghijklmnopqrstuvwxyz'
    ascii_uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    

    ut.Random

    boolean: function()
    bytes: function()
    choice: function()
    chooseAny: function()
    chooseFew: function()
    float: function()
    int: function()
    randChoiceAsStr: function()
    randomAsciiLetters: function()
    randomAsciiLowercase: function()
    randomAsciiUppercase: function()
    randomDigits: function()
    randomRange: function()
    randomSpecials: function()
    shuffle: function()
    

    ut.Sorting

    bubble_sort: function()
    merge_sort: function()
    quick_sort: function()
    

    ut.Search

    binary_search: function()
    interpolation_search: function()
    linear_search: function()
    

    ut.BuiltIns

    abs: function()
    all: function()
    any: function()
    callable: function()
    enumerate: function()
    execution_time: function()
    fact: function()
    max: function()
    median: function()
    min: function()
    range: function()
    recursive_all: function()
    recursive_any: function()
    recursive_enumerate: function()
    recursive_fact: function()
    recursive_len: function()
    recursive_max: function()
    recursive_min: function()
    recursive_sum: function()
    recursive_zip: function()
    sum: function()
    zip: function()
    bin(): function()
    oct(): function()
    hex(): function()
    chr(): function()
    ord(): function()
    

    Examples

    ut.Random.choice([1, 2, 3, 4, 5])
    > 5
    ut.Random.choice([1, 2, 3, 4, 5])
    > 2
    
    
    ut.Random.int(1, 1000)
    > 429
    ut.Random.int(1, 1000)
    > 664
    
    ut.Random.float(1, 14)
    > 3.568412280886703
    
    ut.Sorting.quick_sort([29, 53, 11, 59])
    > [ 11, 29, 53, 59 ]
    
    ut.Search.binary_search([1, 2, 3, 4, 5, 6, 7, 8, 9], 4)
    > 3 (Index of key)
    
    ut.Search.binary_serch([1, 2, 3], 4)
    > -1 (Not found)
    
    ut.BuiltIns.range(1, 100)
    > [
         1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
        13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
        25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
        37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
        49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
        61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
        73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
        85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
        97, 98, 99
      ]
    
    ut.BuiltIns.range(1, 10, 2)
    > [ 1, 3, 5, 7, 9 ]
    
    ut.BuiltIns.range(10, 1, -1)
    > [
        10, 9, 8, 7, 6,
         5, 4, 3, 2
      ]
    
    ut.BuiltIns.max([42, 56, 20])
    > 56 (Biggest element in array)
    
    ut.BuiltIns.min([42, 56, 20])
    > 20 (Smallest element in array)
    
    ut.BuiltIns.enumerate([10, 11, 12, 13])
    > [ [0, 10], [1, 11], [2, 12], [3, 13] ]
    
    ut.BuiltIns.zip([1, 2, 3], [3, 2, 1])
    > [ [1, 3], [2, 2], [3, 1] ]
    
    ut.BuiltIns.zip([1, 2, 3], [4, 5, 6, 7, 8])
    > [ [ 4, 1 ], [ 5, 2 ], [ 6, 3 ], [ 7, undefined ], [ 8, undefined ] ]
    
    ut.BuiltIns.execution_time(() => {
        for (let _ of BuiltIns.range(1000)) {}
    })
    > 0.15330000221729279
    
    ut.BuiltIns.bin(100)
    > 1100100
    
    ut.BuiltIns.hex(429635635)
    > 199bb833
    
    ut.BuiltIns.chr(425)
    > Ʃ
    
    ut.BuiltIns.ord('Ʃ')
    > 425
    

    Install

    npm i useful-ut

    DownloadsWeekly Downloads

    7

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    28.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar