Giter VIP home page Giter VIP logo

strings's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

strings's Issues

Add "prepend" method

Add a new .prepend(...values) method that prepends the given values onto the string:

Example

Str('awesome').prepend('Supercharge ', 'is ').get()

// 'Supercharge is awesome'

Add "beforeLast" method

Add a new .beforeLast(delimiter) method that returns everything from the string before the last occurrence of the given delimiter. This method returns the entire string if the delimiter doesn’t exist in the string.

Example

Str('Supercharge-is-awesome').beforeLast('-').get()

// 'Supercharge-is'

Add "padLeft" method

Add a new .padLeft(length, pad) method that pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start of the current string.

Example

Str('Marcus').padLeft(10, '.').get()
// '....Marcus'

Limit string by number of words

Is there a way to limit a string by the number of words? I tried a few ways to get at it.

Str("To be or not to be").words().limit(3).get()

I'm doing it right now with:

Str(text).words().slice(0,5).join(" ") + "...

Add "concat" method

The str.concat(addon) method appends the given addon to the string.

Example

const str = Str('Supercharge').concat('is awesome').get()

// 'Supercharge is awesome'

Add method: isCamelCase

Hey! What about adding a new method to check whether a given string is written in CamelCase or not? This should work with a simple Regex like: /^[a-z]+([A-Z][a-z]+)+$/g.

Examples:

Str("helloWorld").isCamelCase() // true
Str("helloWOrld").isCamelCase() // false
Str("hello").isCamelCase() // false
Str("hellO").isCamelCase() // false
Str("Hello").isCamelCase() // false

If that's okay I would like to submit a PR :)

Add "append" method

Add a new .append(...values) method that appends the given values to the string:

Example

Str('Supercharge').append(' is', ' awesome').get()

// 'Supercharge is awesome'

Add "trimStart" method

The str.trimStart() method removes all whitespace at the beginning of a string.
Example

Str('    Supercharge  ').trimStart().get()

// 'Supercharge  '

Add "afterLast" method

Add a new .afterLast(delimiter) method that returns everything from the string after the last occurrence of the given delimiter. This method returns the entire string if the delimiter doesn’t exist in the string.

Example

Str('Supercharge-is-awesome').afterLast('-').get()

// 'awesome'

Add "padRight" method

Add a new .padRight(length, pad) method that pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of the current string.

Example

Str('Marcus').padRight(10, '.').get()
// 'Marcus....'

Add "finish" method

Add a new .finish(suffix) method that adds a single instance of the given suffix value to the end of the string if it doesn’t already ends with the given suffix.

Example

Str('https://github.com').finish('/').get()
// 'https://github.com/'

Str('https://github.com/').finish('/').get()
// 'https://github.com/'

Add "endsWith" method

The str.endsWith(needle) method determines whether a string ends with the given needle.

Example

Str('Supercharge is awesome').endsWith('some')

// true

Str('Supercharge is awesome').endsWith('Super')

// false

Add Method: equalsIgnoreCase

Hello, I think a useful method to add would be one that checks for equality while ignoring the character cases. This would be called something like equalsIgnoreCase

Some examples:

Str('SUPERCHARGE').equalsIgnoreCase('supercharge') //true
Str('SuPeRcHaRgE').equalsIgnoreCase('sUpErChArGe') //true
Str('SUPERCHARGE').equalsIgnoreCase('SLOWCHARGE') //false
Str('SuPeR').equalsIgnoreCase('sUpErChArGe') //false

If this sounds good I'd love to create a PR

Add "limit" method

The str.limit(limit, end = '…') method returns the first limit characters and ends the limited string with end.

Example

Str('Supercharge').limit(5, ' ->').get()

// 'Super ->'

Add "substr" method

The str.substr(start, length) method returns the substring of length length starting from position start.

Example

Str('Supercharge').substr(0, 5).get()

// 'Super'

Add method: isUuid

Implement an isUuid method that returns true if the wrapped string value is a valid UUID. Returns false otherwise

Requirements

Add "ucFirst" method

The str.ucFirst() method uppercases the first character of the string.

Example

Str('superCHARGE').ucFirst().get()

// 'SuperCHARGE'

Str.random(length) not working

I am using random function to generate a token as shown in the code below
const Str=require('@supercharge/strings); const token = Str.random(50);
but its giving me the error
TypeError: Str.random is not a function
The same code was working when i used it some months before.
Is random function is removed ?

Add "trimEnd" method

The str.trimEnd() method removes all whitespace at the end of a string.

Example

Str('  Supercharge     ').trimEnd().get()

// '  Supercharge'

Add "startsWith" method

The str.startsWith(needle) method determines whether a string starts with the given needle.

Example

Str('Supercharge').startsWith('Super')

// true

Str('Supercharge').startsWith('super')

// false

Add replaceLast Method

The search method returns the position of the first occurrence of a specified text in a string

@marcuspoehls can you assign this to me and add label as hactoberfest.

Add "split" method

The str.split(separator) splits the string at the given separator and returns an array of all separated strings.

Example

Str('Supercharge-is-awesome!').split('-')

// [ 'Supercharge', 'is', 'awesome!' ]

Add "replace" method

Add a new .replace(search, replace) method that replaces the first occurrence of the given search value with the replacing value.

Example

Str('Supercharge is nice').replace('nice', 'sweet').get()

// 'Supercharge is sweet'

Add "start" method

Add a new .start(prefix) method that prepends a single instance of the given prefix value to the start of the string if it doesn’t already start with the given prefix.

Example

Str('repos/supercharge').start('/').get()
// '/repos/supercharge'

Str('/repos/supercharge').start('/').get()
// '/repos/supercharge'

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.