1
0
forked from Mirror/wren

19 Commits

Author SHA1 Message Date
a437e804ba Added String.fromByte with docs and unit test 2019-02-27 08:10:54 -05:00
09f4beff4a Add trim methods on String:
- trim()
- trim(chars)
- trimEnd()
- trimEnd(chars)
- trimStart()
- trimStart(chars)
2018-07-15 10:48:56 -07:00
8d313be3ce Make it an error to skip or take a negative count. 2017-03-15 07:22:44 -07:00
32aa43d1df Split and replace in wren. 2017-03-07 21:15:06 -05:00
6845328661 Tweak String.indexOf(_,_) a bit.
- Simplify the arithmetic a little in wrenStringFind().
- Allow the start to be negative.
- Even more tests.
- Docs.
2016-08-03 22:19:34 -07:00
1f84a10f44 Implement String indexOf(needle, startIndex) 2016-07-14 01:23:01 -02:30
d46dfc9500 Allow "*" on lists and strings to repeat them.
This is not implemented on Sequence because, at least for lists and
strings, I think users expect an eager result. Multiplying a string
should give you back a string, not a lazy sequence of repeated
characters.

This also mirrors "+" on strings and lists, which is eager. I like the
idea of having a general guideline that operators are eager.

Repetition is useful for arbitrary sequences, but for that maybe we
should add a "repeat()" method.
2016-02-24 07:48:03 -08:00
6ff5fb9ff2 Allow empty ranges at the end of a sequence. 2015-12-06 10:37:58 -08:00
58e4d26648 "IO" -> "System".
Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
2015-09-15 07:46:09 -07:00
fe143644b3 Rationalize string lengths.
The .count getter on string returns the number of code points. That's
O(n), but it's consistent with the rest of the main string API.

If you want the number of bytes, it's "string".bytes.count.

Updated the docs.

Fixes 68. Woo!
2015-09-11 21:33:26 -07:00
c0b5ec9f15 Move codePointAt() to separate CodePointSequence class. 2015-09-11 07:56:01 -07:00
bda9ad880a Flesh out string byte handling a bit:
- Get rid of public byteAt(_) method on strings. It's redundant and
  longer than .bytes[_].
- Implement bytes.count natively so it's O(1).
2015-09-10 23:52:18 -07:00
783a5b750a Get ranges working in string subscripts (again).
Now with UTF-8 hotness!
2015-09-01 22:14:55 -07:00
2e83f056c1 No more default constructors.
Fixes #296.
2015-09-01 08:16:04 -07:00
bf730bb953 More tests for invalid code points. 2015-06-27 08:11:58 -07:00
72c38a59ce More stuff for working with strings and bytes!
- "\x" escape sequence to put byte values in strings: "\x34"
- String.byteAt(index) gets value of byte in string.
- String.bytes returns a raw sequence of bytes for a string.
- String.codePointAt(index) gets the code point at an offset as a raw number.
2015-03-27 20:44:07 -07:00
7d45dda383 String.fromCodePoint(). Fix #219. 2015-03-27 07:43:36 -07:00
be11d09bd8 Store hash code in strings.
Makes string equality and string map keys much faster.
Also did some other general string clean-up.
2015-03-18 07:09:03 -07:00
64eccdd9be Reorganize tests and benchmark scripts.
Mainly to get rid of one top level directory. But this will
also be useful when there are tests of the embedding API.
2015-03-14 12:45:56 -07:00