GithubHelp home page GithubHelp logo

Library improvements about stringy HOT 8 OPEN

danielstjules avatar danielstjules commented on June 10, 2024
Library improvements

from stringy.

Comments (8)

danielstjules avatar danielstjules commented on June 10, 2024 1

Alright! My 3rd point was about the fact that "substringing" is very common when manipulating strings, that's why I expected these methods to be merged in the main library, allowing the use an out-of-the-box swiss knife, requiring no config and no overriding.

I definitely think the package is useful, I just think it's hard to come up with terse method names that describe their behaviour. For example:

s('What are your plans today?')->substringAfterFirst('plans ');
// => "today"

// An equivalent using only core methods
s('What are your plans today?')->split('plans ')[1] ?: false

substringCount
// same as countSubstr in Stringy core

// Some of the other methods require a bit more aerobatics with just core,
// so I can see their benefit :)

The core library def has quite a few "substring" methods already :) But I think traits are the right way to go, letting people easily customize at will!

from stringy.

danielstjules avatar danielstjules commented on June 10, 2024 1

@TCB13 Agreed! Building off the core methods can get verbose too for some of those operations as the array primitives in PHP aren't great. Definitely appreciate the library :)

from stringy.

danielstjules avatar danielstjules commented on June 10, 2024
  • Package renaming sounds fine, probably easier to remember as you said
  • Join sounds good ๐Ÿ‘
  • I don't think SubStringy belongs in the core, and could probably be implemented as a Trait if you wanted a bit more flexibility :) TCB13/SubStringy#1 #87 (comment)

from stringy.

TCB13 avatar TCB13 commented on June 10, 2024

@bpolaszek I had this SubStringy discussion previously with @danielstjules - the first versions were actually a PR to this repo. There are also other "extensions" that follow this principle.

We're currently in the process of making SubStringy into a trait.

from stringy.

TCB13 avatar TCB13 commented on June 10, 2024

@bpolaszek @danielstjules TCB13/SubStringy is now a trait.

from stringy.

bpolaszek avatar bpolaszek commented on June 10, 2024

Hello @danielstjules @TCB13,

Alright! My 3rd point was about the fact that "substringing" is very common when manipulating strings, that's why I expected these methods to be merged in the main library, allowing the use an out-of-the-box swiss knife, requiring no config and no overriding.

But I understand your point, and the use of a trait is indeed a better approach that a vertical inheritance.

Do you want me to do a PR for points 1 & 2?

Thank you,
Ben

from stringy.

danielstjules avatar danielstjules commented on June 10, 2024

@TCB13 Awesome! :)

from stringy.

TCB13 avatar TCB13 commented on June 10, 2024

@danielstjules An equivalent using only core methods those methods are hard on the eyes. This is one of the reasons why I added the substring methods. Easier to use specially when you use an IDE / sublime.

from stringy.

Related Issues (20)

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.