I have a few (typed) array additions I'd like to see added, detailed
in this repo. By any chance, how many of these do you all see worth
adding, if any?
https://github.com/isiahmeadows/array-additions-proposal/
-
Isiah Meadows
m...@isiahmeadows.com
Looking for web consulting? Or a new websi
Maybe this analogue to the `for (const ... of ...)`:
```js
function keyList(map) {
const list = new Array(map.size)
const iter = map.keys()
while (const {done, value} = iter.next(); !done) {
list.push(value)
}
return list
}
```
But in general, the more I've thought a
I don't get it. Please give an example of the per-iteration initialization
in the while loop... (the for-loop version before `;` does it before
iteration, not per-iteration)
On Mon, 26 Mar 2018 at 07:20 Isiah Meadows wrote:
> As a counterpoint, Rust and Swift are the opposite: it's only defined
Even in TypeScript, `never` (the type of functions that never return -
throwing ≠ returning) is the subtype of *all* types, even primitives.
-
Isiah Meadows
m...@isiahmeadows.com
Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com
On S
Edits:
1. s/Haskell/Swift/g
2. Most of my utility has been in things like random data.
Now that I take a second look at this, maybe it's better as just a
utility function, not in the standard. (There isn't really anything
this could provide that aren't possible otherwise, and it's not as
broad of
On Sun, Mar 25, 2018 at 6:20 PM, 月の影 <19511...@qq.com> wrote:
> Sometimes I got a infinity iterable sequences, I may want a partial spreed
> syntax. `...iterableObject{from, to}`
>
> For example:
>
> ```js
> function *fibonacci() {
> let a = 0, b = 1
> while(1) {
> [a, b] = [b, a +
Edit: that `while (i < count)` should be `while (i < end)`, where `end
= length * count`. My bad.
-
Isiah Meadows
m...@isiahmeadows.com
Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com
On Sun, Mar 25, 2018 at 10:21 PM, Isiah Meadows
That *could* repeat an array, but it's not very good as a polyfill (it
creates too many intermediate arrays). I'd expect a polyfill would be
closer to this:
```js
const ToInteger = x => (x = +x; x - x % 1)
Array.prototype.repeat = function repeat(count) {
count = ToInteger(count)
let o =
I like this idea, and it has plenty of precedent in other languages
(Python, Haskell, Clojure, etc.). It's more useful for arrays in my
experience than even for strings.
-
Isiah Meadows
m...@isiahmeadows.com
Looking for web consulting? Or a new website?
Send me an email and we can get started
As a counterpoint, Rust and Swift are the opposite: it's only defined
in the consequent branch, not the alternate. So it could go both ways.
But if a value is useful in both branches, I'd prefer to just define
the variable in a separate statement, to clarify that it's useful in
both branches (expl
Per-iteration scoping would work just as it does with `for (const foo
of bar) { ... }` now, and if it were to make it in (I'm mildly against
the feature, BTW), I'd prefer it to be per-iteration like that.
-
Isiah Meadows
m...@isiahmeadows.com
Looking for web consulting? Or a new website?
Send
Sometimes I got a infinity iterable sequences, I may want a partial spreed
syntax. `...iterableObject{from, to}`
For example:
```js
function *fibonacci() {
let a = 0, b = 1
while(1) {
[a, b] = [b, a + b]
yield a
}
}
console.log([...fibonacci(){3, 5}]) // [3, 5, 8]
Not a bad idea -- I agree that it really belongs here, but its value is
much higher in something like TypeScript, where you can keep the typing
signature but have a missing implementation.
On Sat, Mar 24, 2018 at 3:32 AM Isiah Meadows
wrote:
> I would suggest, if you have support in your editor,
On Sun, Mar 25, 2018 at 1:40 PM, Claude Pache
wrote:
>
>
> Le 25 mars 2018 à 20:27, Cyril Auburtin a
> écrit :
>
> String and Array share a few methods.
>
> I think `repeat` could exist for Array as well
>
> At the moment are other more verbose ways to do so:
>
> - `Array.from({length: n}, () =>
> Le 25 mars 2018 à 20:27, Cyril Auburtin a écrit :
>
> String and Array share a few methods.
>
> I think `repeat` could exist for Array as well
>
> At the moment are other more verbose ways to do so:
>
> - `Array.from({length: n}, () => 'foo')`
> - `Array(n).fill('foo')`
> - `[].concat(...A
I'm guessing this would be an appropriate polyfill:
```
Array.prototype.repeat = function repeat(count) {
let output = this;
while (--count) {
output = output.concat(this);
}
return output;
};
```
On Sun, Mar 25, 2018 at 12:27 PM, Cyril Auburtin
wrote:
> String and Array share a few
String and Array share a few methods.
I think `repeat` could exist for Array as well
At the moment are other more verbose ways to do so:
- `Array.from({length: n}, () => 'foo')`
- `Array(n).fill('foo')`
- `[].concat(...Array.from({length: 3}, () => ['x', 'y']))`
- `[].concat(...Array(3).fill(['x
Obviously scoped, agreed, but again how would you allow scoped
initialization upon each iteration, or is it your preference not to allow
that? (again, initializers-as-expressions allows that, despite the other
concerns).
On Sun, 25 Mar 2018 at 10:57 Isiah Meadows wrote:
> 1. My concern with `whi
18 matches
Mail list logo