Skip to content

[Replacement]: as-array #515

@gameroman

Description

@gameroman

Package to replace

as-array

Suggested replacemen

function asArray(data) {
  if (data == null) return []
  if (Array.isArray(data)) return data
  if (typeof data !== 'string' && data[Symbol.iterator]) return Array.from(data)
  return [data]
}

Manifest type

micro-utility (tiny utility replaceable with native code or removal)

Rationale

Should not be its own package

Availability

all modern browsers and runtimes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions