chubbyphp/chubbyphp-typescript

PHP port of JavaScript's Array and Map APIs with TypeScript-style generics

Maintainers

Package info

github.com/chubbyphp/chubbyphp-typescript

pkg:composer/chubbyphp/chubbyphp-typescript

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

dev-master / 1.0.x-dev 2026-06-20 16:34 UTC

This package is auto-updated.

Last update: 2026-06-20 16:34:35 UTC


README

CI Coverage Status Mutation testing badge Latest Stable Version Total Downloads Monthly Downloads

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A PHP implementation of JavaScript's Array and Map APIs with TypeScript-style generics and Test262-inspired coverage.

Requirements

  • php: ^8.3

Installation

Through Composer as chubbyphp/chubbyphp-typescript.

composer require chubbyphp/chubbyphp-typescript "^1.0"

Usage

Arr (Array)

A PHP implementation of the JavaScript Array class, including sparse-array semantics and chainable methods. See the full documentation for API reference and examples.

use Chubbyphp\Typescript\Arr;

$arr = new Arr(1, 2, 3, 4, 5);
$arr->shift();
$arr->pop();
$arr = $arr->map(static fn (int $v): int => $v * 2);
$arr->push(10);
// iterator_to_array($arr->values()) => [4, 6, 8, 10]

$arr = Arr::from([1, 2, 3, 4, 5], static fn (int $v): int => $v * 2);
// iterator_to_array($arr->values()) => [2, 4, 6, 8, 10]

Map

A PHP implementation of the JavaScript Map class with SameValueZero key equality and insertion-order iteration. See the full documentation for API reference and examples.

use Chubbyphp\Typescript\Map;

$map = new Map([
    ['a', 1],
    ['b', 2],
]);
$map->set('c', 3);
$map->delete('b');
// $map->toArray() => [['a', 1], ['c', 3]]

$map->forEach(static fn (int $v, string $k) => print($k.':'.$v));

Copyright

2026 Dominik Zogg