Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cBuffer] String Manipulation Helpers #72

Open
hnakamur opened this issue Sep 17, 2012 · 6 comments
Open

[cBuffer] String Manipulation Helpers #72

hnakamur opened this issue Sep 17, 2012 · 6 comments
Assignees

Comments

@hnakamur
Copy link
Collaborator

I propose lev.string module.

It should be upper-compatible to lua's string module.

These are draft APIs for additional functions.

string.startsWith(s, prefix):boolean
string.endsWith(s, prefix):boolean
string.indexOf(s, predicate_func, startIndex):number or nil
string.lastIndexOf(s, predicate_func, startIndex):number or nil

string.ltrim(s, trimChars):string
string.rtrim(s, trimChars):string
string.trim(s, trimChars):string

string.lpad(s, resultLen, padding):string
string.rpad(s, resultLen, padding):string

@ghost ghost assigned hnakamur Sep 17, 2012
@kristate
Copy link
Member

Let's first implement this API into buffers.
I am also thinking about a better API for string transitions.

@hnakamur
Copy link
Collaborator Author

I realized these APIs should be implemented as a separate library because these does not depend on lev.
As for buffers, we should think of appropriate APIs for buffers.

@dvv
Copy link
Contributor

dvv commented Sep 25, 2012

+1 for not pulling this into the core. lua-nucleo has hard-tested and polished routines

@kristate
Copy link
Member

It might be smart to modify the string library and add these additions. Reopening for cBuffer support

@kristate kristate reopened this Sep 25, 2012
@dvv
Copy link
Contributor

dvv commented Sep 25, 2012

doesn't it contradict the initial goals? strings are generic lua, not fast and robust async io we've been trying to implement?

@kristate
Copy link
Member

@dvv thank-you for your comment. All IO will go through cBuffers and having some of these functions added to buffers is fine. As for strings, they are still useful in certain places and it might be good to add these methods to the standard string library.

For example:

string.startsWith(s, prefix):boolean
string.endsWith(s, prefix):boolean

these are good functions to have because they only check the contents of memory -- there may be moments were it is important to use strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants