Wondering what’s next for npm?Check out our public roadmap! »

    string-jaws

    1.0.4 • Public • Published

    string-jaws

    The string-jaws library exported as Node.js modules.

    Docs

    String-Jaws rips apart strings from Chars, Words, Items and Now Lines! String manipulation that covers functions for chars, words, items (item delimiter) and Lines (/n) List of all functions are below - documentation coming soon

    Installation

    npm install string-jaws
    

    String Functions

    Anything and everthing you need to for string manipulation - the list of fuctions are below Let me know if you need anything else to add :)

    //VALIDATION
    console.log('isChar:', _$.isChar('a'))
    
    console.log('isCharLC:', _$.isCharLowerCase('a'))
    console.log('isCharUC:', _$.isCharUpperCase('a'))
    
    console.log('isCharSP:', _$.isSpecial('!'))
    
    console.log('isInt:', _$.isInt('1'))
    console.log('isFloat:', _$.isFloat('1'))
    
    console.log('isNothing:', _$.isNothing(''))
    console.log('isSpace:', _$.isSpace(' '))
    
    console.log('---------------------------')
    
    //CHARS
    console.log('-------CHARS--------')
    
    console.log('chars:', _$.chars('sample'))
    
    let cnt = _$.charCount('Mike Was Here')
    console.log('count:',cnt)
    
    let charPos = _$.char('Bonifacio',2) //n
    console.log('charPos:',charPos)
    
    let charRange = _$.charRange('Bonifacio',2,4) //nifa
    console.log('charRange:',charRange)
    
    console.log('fChar:', _$.charFirst('Mike Was Here')) 
    console.log('lChar:', _$.charLast('Mike Was Here'))
    
    console.log('fChar-range of 2:', _$.charFirst('Mike Was Here',2)) //Mik
    console.log('lChar-range of 4:', _$.charLast('Mike Was Here',4)) //Here
    
    console.log('Found Char e:', _$.charFound('Mike Was Here','e')) //true/false
    console.log('Found Char Count "e":', _$.charFoundCount('Mike Was Here','e')) //int 3
    console.log('Found Char "e" Indexs:', _$.charFoundIndexs('Mike Was Here','e')) //[ 3, 10, 12 ]
    
    console.log('Delete Char:', _$.charDeleteAt('Mike Was Here', 2))
    console.log('Insert Char:', _$.charInsertAt('MikeBoni', 4, '-'))
    console.log('Replace Char:', _$.charReplaceAt('Mike-', 4, 'B'))
    
    console.log('Find Char Index:', _$.charFindIndex('Mike Bonifacio', 'B'))
    
    console.log('Find Char and Replace:', _$.charReplace('Mike - Bonifacio', '-', ':'))
    
    console.log('charRepeat:', _$.charRepeat('w',3))
    
    console.log('Delete Char "a":', _$.charDelete('Mike Was Here. Yes he was Here', 'a'))
    console.log('Delete All Char "a":', _$.charDelete('Mike Was Here. Yes he was Here', 'a', true))
    
    console.log('---------------------------')
    
    //WORDS
    console.log('-------WORDS--------')
    
    let words = _$.words('Mike Was Here')
    console.log('words:',words)
    
    let wordCount = _$.wordCount('Mike Was Here')
    console.log('wordCount:',wordCount)
    
    let wordPos = _$.word('Mike Was Here',1) //Was
    console.log('WordPos:',wordPos)
    
    let wordRange = _$.wordRange('Mike Was Here',1,2) //Was Here
    console.log('wordRange:',wordRange)
    
    let fWord = _$.wordFirst('Mike Was Here')
    console.log('fWord:',fWord)
    
    let lWord = _$.wordLast('Mike Was Here')
    console.log('lWord:',lWord)
    
    let fWordRange = _$.wordFirst('Mike Was Here Today At Home', 2)
    console.log('fWord-range of 2:',fWordRange)
    
    let lWordRange = _$.wordLast('Mike Was Here Today At Home', 2)
    console.log('lWord-range of 2:',lWordRange)
    
    console.log('wordFind:', _$.wordFound('Mike Was Here', 'Was'))
    
    console.log('Found Word Count "was":', _$.wordFoundCount('Mike Was Here. Yes he was Here','was')) //int 2
    console.log('Found Word "was" Indexs:', _$.wordFoundIndexs('Mike Was Here. Yes he was Here','was')) //[ 1, 5 ]
    
    console.log('Delete Word "Bonifacio" idx 2:', _$.wordDeleteAt('Mike Was Bonifacio. Yes was here!', 2)) //Bonifacio is deleted
    console.log('Insert Word: "Hello" idx 2:', _$.wordInsertAt('Mike Was Bonifacio. Yes was here!', 2, 'Hello'))
    console.log('Replace Word: "Bonifacio" w "Boni" idx 2:', _$.wordReplaceAt('Mike Was Bonifacio. Yes was here!', 2, 'Boni'))
    
    console.log('Find Word Index:', _$.wordFindIndex('Mike Bonifacio Was Here', 'was'))
    
    console.log('Find Word and Replace:', _$.wordReplace('Mike NOT Here', 'not', 'IS'))
    
    console.log('wordRepeat:', _$.wordRepeat('Mike Was Here',3))
    
    console.log('Delete Word "was":', _$.wordDelete('Mike Was Here. Yes he was Here', 'was'))
    console.log('Delete All Words "was":', _$.wordDelete('Mike Was Here. Yes he was Here', 'was', true))
    
    console.log('---------------------------')
    
    
    //ITEMS
    console.log('-------ITEMS--------')
    
    let items = _$.items('Mike, Was, Here')
    console.log('items:',items)
    
    let itemCount = _$.itemCount('Mike, Was, Here')
    console.log('itemCount:',itemCount)
    
    let itemPos = _$.item('Mike, Was, Here',1) //Was
    console.log('itemPos:',itemPos)
    
    let itemRange = _$.itemRange('Mike, Was, Here',1,2) //Was Here
    console.log('itemRange:',itemRange)
    
    let fitem = _$.itemFirst('Mike, Was, Here')
    console.log('fitem:',fitem)
    
    let litem = _$.itemLast('Mike, Was, Here')
    console.log('litem:',litem)
    
    let fitemRange = _$.itemFirst('Mike Was, Here Today, At Home', 2)
    console.log('fitem-range of 2:',fitemRange)
    
    let litemRange = _$.itemLast('Mike Was, Here Today, At Home', 2)
    console.log('litem-range of 2:',litemRange)
    
    console.log('itemFind:', _$.itemFound('Mike, Was, Here', 'was'))
    
    console.log('Found item Count "was":', _$.itemFoundCount('Mike,Was,Here.,Yes,he,was,Here','was')) //int 2
    console.log('Found item "was" Indexs:', _$.itemFoundIndexs('Mike,Was,Here.,Yes,he,was,Here','was')) //[ 1, 5 ]
    
    console.log('Delete item "Bonifacio" idx 2:', _$.itemDeleteAt('Mike, Was, Bonifacio., Yes, was, here!', 2)) //Bonifacio is deleted
    console.log('Insert item: "Hello" idx 2:', _$.itemInsertAt('Mike, Was, Bonifacio. Yes, was, here!', 2, 'Hello'))
    console.log('Replace item: "Bonifacio" w "Boni" idx 2:', _$.itemReplaceAt('Mike, Was, Bonifacio., Yes, was, here!', 2, 'Boni'))
    
    console.log('Find item Index:', _$.itemFindIndex('Mike, Bonifacio, Was, Here', 'was'))
    
    console.log('Find item and Replace:', _$.itemReplace('Mike, NOT, Here', 'not', 'IS'))
    
    console.log('itemRepeat:', _$.itemRepeat('Mike, Was, Here',3))
    
    console.log('Delete items "was":', _$.itemDelete('Mike, Was, Here., Yes, he, was, Here', 'was'))
    console.log('Delete All items "was":', _$.itemDelete('Mike,Was,Here.,Yes,he,was,Here', 'was', true))
    
    console.log('---------------------------')
    
    //LINES
    console.log('-------LINES--------')
    
    console.log('lines:',_$.lines('Mike/nWas/nHere'))
    console.log('lineCount:',_$.lineCount('Mike/nWas/nHere'))
    
    let linePos = _$.line('Mike/nWas/nHere',1) //Was
    console.log('linePos:',linePos)
    
    let lineRange = _$.lineRange('Mike/nWas/nHere',1,2) //Was Here
    console.log('lineRange:',lineRange)
    
    let fline = _$.lineFirst('Mike/nWas/nHere')
    console.log('firstline:',fline)
    
    let lline = _$.lineLast('Mike/nWas/nHere')
    console.log('lastline:',lline)
    
    let RFlineRange = _$.lineFirst('Mike Was/nHere Today/nAt Home', 2)
    console.log('line-range of 2:',RFlineRange)
    
    let RLlineRange = _$.lineLast('Mike Was/nHere Today/nAt Home', 2)
    console.log('line-range of 2:',RLlineRange)
    
    console.log('Delete item "Bonifacio" idx 2:', _$.lineDeleteAt('Mike/nWas/nBonifacio./nYes/nwas/nhere!', 2)) //Bonifacio is deleted
    console.log('Insert item: "Hello" idx 2:', _$.lineInsertAt('Mike/nWas/nBonifacio./nYes/nwas/nhere!', 2, 'Hello'))
    console.log('Replace item: "Bonifacio" w "Boni" idx 2:', _$.lineReplaceAt('Mike/nWas/nBonifacio./nYes/nwas/nhere!', 2, 'Boni'))
    
    console.log('---------------------------')
    
    //MISC
    console.log('-------MISC--------')
    
    console.log('getNumbers:',_$.getNumbers())
    console.log('getChars:',_$.getChars())
    console.log('getSpecial:',_$.getSpecial())
    
    console.log('padded:', _$.pad('12',2, '0'))
    console.log('lPadded:', _$.padLeft('12',2, '0'))
    console.log('rPadded:', _$.padRight('12',2, '0'))
    
    console.log('cleanSpecial:', _$.cleanSpecial('ABCDefghIJKLmnopQRSTUVwxyz1234567890!@#$%^&*()_+-={}[]|\:;<>,.?`~'))
    console.log('cleanNumbers:', _$.cleanNumbers('ABCDefghIJKLmnopQRSTUVwxyz1234567890!@#$%^&*()_+-={}[]|\:;<>,.?`~'))
    console.log('cleanAlpha:', _$.cleanAlpha('ABCDefghIJKLmnopQRSTUVwxyz1234567890!@#$%^&*()_+-={}[]|\:;<>,.?`~'))
    
    console.log('strRepeat:', _$.strRepeat('WOW 123',2, ' '))
    
    console.log('deleteAt:', _$.deleteAt('Mike Was - Here',1,'-'))
    console.log('insertAt:', _$.insertAt('Mike Was - Here',1, 'WOW', '-'))
    console.log('replaceAt:', _$.replaceAt('Mike Was - Here',1, 'WOW', '-'))
    
    console.log('findIndex:', _$.findIndex('Mike Was - Here Me','Here'))
    
    //SPECS
    console.log('-------SPECS--------')
    console.log('Mike Bonifacio B1uttn58!2')
    const specs = _$.strSpecs('Mike Bonifacio B1uttn58!2')
    console.log('Specs:', specs)
    

    Support

    Tested in Chrome 53-54, Firefox 48-49, IE 11, Edge 14, Safari 9-10, Node.js 6-7, & PhantomJS 2.1.1.
    Automated test runs are available.

    Install

    npm i string-jaws

    DownloadsWeekly Downloads

    1

    Version

    1.0.4

    License

    ISC

    Last publish

    Collaborators

    • avatar