Add "extend" to help putting multiple items from one list into another

Open
#687 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
web-dev

Research direction

The issue names no files or tests; start by tracing the existing list assignment, append, and “split by” handling in the hyperscript implementation. Done means the proposed extend $assignees with ... syntax accepts multiple items from another list, including the shown data-attribute case, while the empty-value behavior is understood or separately scoped.

Written by the indexing model from the issue text.

Description

In Python we have "list.extend(otherlist)" as a multi-item "append" basic function.

I found that this is a bit tedious in hyperscript (or of course I might be missing something). Especially if I'm parsing something where the result could be a non-list (which is also interesting in its own from a typing perspective that splitting an empty string results in a non-list):

<span data-assignees="a b c"
  _="init
          set $assignees to my @data-assignees split by ' '
          if not $assignees then set $assignees to []" />

I wish I could do this instead:

<span data-assignees="a b c"
  _="init
          set $assignees to []
          extend $assignees with my @data-assignees split by ' '
        " />

We could also consider whether "split by" should always return a list (I'm not quite sure what's going on there when @data-assignees is an empty value) but that's orthogonal to the extend ability.

Dominant language
JavaScript
Stars
3.8k
Forks
171
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bigskysoftware/_hyperscript

All issues in bigskysoftware/_hyperscript

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.