Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Don't show changes in generated files when doing git diff

gen/** -diff

builtin-*.h -diff
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ codegen: $(QJSC)
$(QJSC) -e -o gen/hello_module.c -m examples/hello_module.js
$(QJSC) -e -o gen/test_fib.c -m examples/test_fib.js
$(QJSC) -C -ss -o builtin-array-fromasync.h builtin-array-fromasync.js
$(QJSC) -C -ss -o builtin-iterator-zip.h builtin-iterator-zip.js
$(QJSC) -C -ss -o builtin-iterator-zip-keyed.h builtin-iterator-zip-keyed.js

debug:
BUILD_TYPE=Debug $(MAKE)
Expand Down
6 changes: 6 additions & 0 deletions amalgam.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const quickjs_libc_c = loadFile("quickjs-libc.c")
const quickjs_libc_h = loadFile("quickjs-libc.h")
const quickjs_opcode_h = loadFile("quickjs-opcode.h")
const gen_builtin_array_fromasync_h = loadFile("builtin-array-fromasync.h")
const gen_builtin_iterator_zip_h = loadFile("builtin-iterator-zip.h")
const gen_builtin_iterator_zip_keyed_h = loadFile("builtin-iterator-zip-keyed.h")

let source = "#if defined(QJS_BUILD_LIBC) && defined(__linux__) && !defined(_GNU_SOURCE)\n"
+ "#define _GNU_SOURCE\n"
Expand All @@ -45,5 +47,9 @@ source = source.replace(/#include "quickjs-opcode.h"/g, quickjs_opcode_h)
source = source.replace(/#include "libregexp-opcode.h"/g, libregexp_opcode_h)
source = source.replace(/#include "builtin-array-fromasync.h"/g,
gen_builtin_array_fromasync_h)
source = source.replace(/#include "builtin-iterator-zip.h"/g,
gen_builtin_iterator_zip_h)
source = source.replace(/#include "builtin-iterator-zip-keyed.h"/g,
gen_builtin_iterator_zip_keyed_h)
source = source.replace(/#include "[^"]+"/g, "")
writeFile(execArgv[2] ?? "quickjs-amalgam.c", source)
216 changes: 110 additions & 106 deletions builtin-array-fromasync.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,116 @@

#include <inttypes.h>

const uint32_t qjsc_builtin_array_fromasync_size = 826;
const uint32_t qjsc_builtin_array_fromasync_size = 863;

const uint8_t qjsc_builtin_array_fromasync[826] = {
0x15, 0x0d, 0x01, 0x1a, 0x61, 0x73, 0x79, 0x6e,
0x63, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
0x72, 0x01, 0x10, 0x69, 0x74, 0x65, 0x72, 0x61,
0x74, 0x6f, 0x72, 0x01, 0x12, 0x61, 0x72, 0x72,
0x61, 0x79, 0x4c, 0x69, 0x6b, 0x65, 0x01, 0x0a,
0x6d, 0x61, 0x70, 0x46, 0x6e, 0x01, 0x0e, 0x74,
0x68, 0x69, 0x73, 0x41, 0x72, 0x67, 0x01, 0x0c,
0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x01, 0x02,
0x69, 0x01, 0x1a, 0x69, 0x73, 0x43, 0x6f, 0x6e,
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6f, 0x72,
0x01, 0x08, 0x73, 0x79, 0x6e, 0x63, 0x01, 0x0c,
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x01, 0x08,
0x69, 0x74, 0x65, 0x72, 0x01, 0x1c, 0x6e, 0x6f,
0x74, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x01, 0x08, 0x63, 0x61,
0x6c, 0x6c, 0x0c, 0x00, 0x02, 0x00, 0xa2, 0x01,
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x01,
0xa4, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x43, 0x02,
0x01, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x01,
0x03, 0x05, 0xaa, 0x02, 0x00, 0x01, 0x40, 0xa0,
0x03, 0x00, 0x01, 0x40, 0xc6, 0x03, 0x00, 0x01,
0x40, 0xcc, 0x01, 0x00, 0x01, 0x40, 0xc8, 0x03,
0x00, 0x01, 0x40, 0x0c, 0x60, 0x02, 0x01, 0xf8,
0x01, 0x03, 0x0e, 0x01, 0x06, 0x05, 0x00, 0x86,
0x04, 0x11, 0xca, 0x03, 0x00, 0x01, 0x00, 0xcc,
0x03, 0x00, 0x01, 0x00, 0xce, 0x03, 0x00, 0x01,
0x00, 0xca, 0x03, 0x01, 0xff, 0xff, 0xff, 0xff,
0x0f, 0x20, 0xcc, 0x03, 0x01, 0x01, 0x20, 0xce,
0x03, 0x01, 0x02, 0x20, 0xd0, 0x03, 0x02, 0x00,
0x20, 0xd2, 0x03, 0x02, 0x04, 0x20, 0xd4, 0x03,
0x02, 0x05, 0x20, 0xd6, 0x03, 0x02, 0x06, 0x20,
0xd8, 0x03, 0x02, 0x07, 0x20, 0x64, 0x06, 0x08,
0x20, 0x82, 0x01, 0x07, 0x09, 0x20, 0xda, 0x03,
0x0a, 0x08, 0x30, 0x82, 0x01, 0x0d, 0x0b, 0x20,
0xd4, 0x01, 0x0d, 0x0c, 0x20, 0x10, 0x00, 0x01,
0x00, 0xa0, 0x03, 0x01, 0x03, 0xc6, 0x03, 0x02,
0x03, 0xc8, 0x03, 0x04, 0x03, 0xaa, 0x02, 0x00,
0x03, 0xcc, 0x01, 0x03, 0x03, 0x08, 0xc4, 0x0d,
0x62, 0x02, 0x00, 0x62, 0x01, 0x00, 0x62, 0x00,
0x00, 0xd3, 0xcb, 0xd4, 0x11, 0xf4, 0xec, 0x08,
0x0e, 0x39, 0x46, 0x00, 0x00, 0x00, 0xdc, 0xcc,
0xd5, 0x11, 0xf4, 0xec, 0x08, 0x0e, 0x39, 0x46,
0x00, 0x00, 0x00, 0xdd, 0xcd, 0x62, 0x07, 0x00,
0x62, 0x06, 0x00, 0x62, 0x05, 0x00, 0x62, 0x04,
0x00, 0x62, 0x03, 0x00, 0xd4, 0x39, 0x46, 0x00,
0x00, 0x00, 0xb0, 0xec, 0x16, 0xd4, 0x98, 0x04,
0x1b, 0x00, 0x00, 0x00, 0xb0, 0xec, 0x0c, 0xdf,
0x11, 0x04, 0xee, 0x00, 0x00, 0x00, 0x21, 0x01,
0x00, 0x30, 0x06, 0xce, 0xb6, 0xc4, 0x04, 0xc3,
0x0d, 0xf7, 0xc4, 0x05, 0x09, 0xc4, 0x06, 0xd3,
0xe0, 0x48, 0xc4, 0x07, 0x63, 0x07, 0x00, 0x07,
0xad, 0xec, 0x0f, 0x0a, 0x11, 0x64, 0x06, 0x00,
0x0e, 0xd3, 0xe1, 0x48, 0x11, 0x64, 0x07, 0x00,
0x0e, 0x63, 0x07, 0x00, 0x07, 0xad, 0x6a, 0xa6,
0x00, 0x00, 0x00, 0x62, 0x08, 0x00, 0x06, 0x11,
0xf4, 0xed, 0x0c, 0x71, 0x43, 0x32, 0x00, 0x00,
0x00, 0xc4, 0x08, 0x0e, 0xee, 0x05, 0x0e, 0xd3,
0xee, 0xf2, 0x63, 0x08, 0x00, 0x8e, 0x11, 0xed,
0x03, 0x0e, 0xb6, 0x11, 0x64, 0x08, 0x00, 0x0e,
0x63, 0x05, 0x00, 0xec, 0x0c, 0xc3, 0x0d, 0x11,
0x63, 0x08, 0x00, 0x21, 0x01, 0x00, 0xee, 0x06,
0xe2, 0x63, 0x08, 0x00, 0xf1, 0x11, 0x64, 0x03,
0x00, 0x0e, 0x63, 0x04, 0x00, 0x63, 0x08, 0x00,
0xa7, 0x6a, 0x2a, 0x01, 0x00, 0x00, 0x62, 0x09,
0x00, 0xd3, 0x63, 0x04, 0x00, 0x48, 0xc4, 0x09,
0x63, 0x06, 0x00, 0xec, 0x0a, 0x63, 0x09, 0x00,
0x8c, 0x11, 0x64, 0x09, 0x00, 0x0e, 0xd4, 0xec,
0x17, 0xd4, 0x43, 0xef, 0x00, 0x00, 0x00, 0xd5,
0x63, 0x09, 0x00, 0x63, 0x04, 0x00, 0x24, 0x03,
0x00, 0x8c, 0x11, 0x64, 0x09, 0x00, 0x0e, 0x5f,
0x04, 0x00, 0x63, 0x03, 0x00, 0x63, 0x04, 0x00,
0x92, 0x64, 0x04, 0x00, 0x0b, 0x63, 0x09, 0x00,
0x4d, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3e,
0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3f, 0x00, 0x00,
0x00, 0xf3, 0x0e, 0xee, 0x9e, 0x62, 0x0a, 0x00,
0x63, 0x07, 0x00, 0x43, 0xef, 0x00, 0x00, 0x00,
0xd3, 0x24, 0x01, 0x00, 0xc4, 0x0a, 0x63, 0x05,
0x00, 0xec, 0x09, 0xc3, 0x0d, 0x11, 0x21, 0x00,
0x00, 0xee, 0x03, 0xe2, 0xf0, 0x11, 0x64, 0x03,
0x00, 0x0e, 0x6d, 0x8c, 0x00, 0x00, 0x00, 0x62,
0x0c, 0x00, 0x62, 0x0b, 0x00, 0x06, 0x11, 0xf4,
0xed, 0x13, 0x71, 0x43, 0x41, 0x00, 0x00, 0x00,
0xc4, 0x0b, 0x43, 0x6a, 0x00, 0x00, 0x00, 0xc4,
0x0c, 0x0e, 0xee, 0x10, 0x0e, 0x63, 0x0a, 0x00,
0x43, 0x6b, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
0x8c, 0xee, 0xe0, 0x63, 0x0c, 0x00, 0xed, 0x4e,
0x63, 0x06, 0x00, 0xec, 0x0a, 0x63, 0x0b, 0x00,
0x8c, 0x11, 0x64, 0x0b, 0x00, 0x0e, 0xd4, 0xec,
0x17, 0xd4, 0x43, 0xef, 0x00, 0x00, 0x00, 0xd5,
0x63, 0x0b, 0x00, 0x63, 0x04, 0x00, 0x24, 0x03,
0x00, 0x8c, 0x11, 0x64, 0x0b, 0x00, 0x0e, 0x5f,
0x04, 0x00, 0x63, 0x03, 0x00, 0x63, 0x04, 0x00,
0x92, 0x64, 0x04, 0x00, 0x0b, 0x63, 0x0b, 0x00,
0x4d, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3e,
0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3f, 0x00, 0x00,
0x00, 0xf3, 0x0e, 0xee, 0x83, 0x0e, 0x06, 0x6e,
0x0d, 0x00, 0x00, 0x00, 0x0e, 0xee, 0x1e, 0x6e,
0x05, 0x00, 0x00, 0x00, 0x30, 0x63, 0x0a, 0x00,
0x42, 0x06, 0x00, 0x00, 0x00, 0xec, 0x0d, 0x63,
0x0a, 0x00, 0x43, 0x06, 0x00, 0x00, 0x00, 0x24,
0x00, 0x00, 0x0e, 0x6f, 0x63, 0x03, 0x00, 0x63,
0x04, 0x00, 0x44, 0x32, 0x00, 0x00, 0x00, 0x63,
0x03, 0x00, 0x2f, 0xc1, 0x00, 0x28, 0xc1, 0x00,
0xcf, 0x28,
const uint8_t qjsc_builtin_array_fromasync[863] = {
0x15, 0x0e, 0x01, 0x28, 0x53, 0x79, 0x6d, 0x62,
0x6f, 0x6c, 0xb7, 0x61, 0x73, 0x79, 0x6e, 0x63,
0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
0x01, 0x2a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74,
0xb7, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x50,
0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x01,
0x1e, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0xb7,
0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
0x01, 0x12, 0x61, 0x72, 0x72, 0x61, 0x79, 0x4c,
0x69, 0x6b, 0x65, 0x01, 0x0a, 0x6d, 0x61, 0x70,
0x46, 0x6e, 0x01, 0x0e, 0x74, 0x68, 0x69, 0x73,
0x41, 0x72, 0x67, 0x01, 0x0c, 0x72, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x01, 0x02, 0x69, 0x01, 0x1a,
0x69, 0x73, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72,
0x75, 0x63, 0x74, 0x6f, 0x72, 0x01, 0x08, 0x73,
0x79, 0x6e, 0x63, 0x01, 0x0c, 0x6d, 0x65, 0x74,
0x68, 0x6f, 0x64, 0x01, 0x08, 0x69, 0x74, 0x65,
0x72, 0x01, 0x1c, 0x6e, 0x6f, 0x74, 0x20, 0x61,
0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x01, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x0c,
0x00, 0x02, 0x00, 0xa2, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x04, 0x01, 0xa4, 0x01, 0x00,
0x00, 0x00, 0x0c, 0x43, 0x02, 0x01, 0x00, 0x05,
0x00, 0x05, 0x01, 0x00, 0x01, 0x03, 0x05, 0xae,
0x02, 0x00, 0x01, 0x40, 0xa4, 0x03, 0x00, 0x01,
0x40, 0xca, 0x03, 0x00, 0x01, 0x40, 0xcc, 0x03,
0x00, 0x01, 0x40, 0xce, 0x03, 0x00, 0x01, 0x40,
0x0c, 0x60, 0x02, 0x01, 0xf8, 0x01, 0x03, 0x0e,
0x01, 0x06, 0x05, 0x00, 0x86, 0x04, 0x11, 0xd0,
0x03, 0x00, 0x01, 0x00, 0xd2, 0x03, 0x00, 0x01,
0x00, 0xd4, 0x03, 0x00, 0x01, 0x00, 0xd0, 0x03,
0x01, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x20, 0xd2,
0x03, 0x01, 0x01, 0x20, 0xd4, 0x03, 0x01, 0x02,
0x20, 0xd6, 0x03, 0x02, 0x00, 0x20, 0xd8, 0x03,
0x02, 0x04, 0x20, 0xda, 0x03, 0x02, 0x05, 0x20,
0xdc, 0x03, 0x02, 0x06, 0x20, 0xde, 0x03, 0x02,
0x07, 0x20, 0x64, 0x06, 0x08, 0x20, 0x82, 0x01,
0x07, 0x09, 0x20, 0xe0, 0x03, 0x0a, 0x08, 0x30,
0x82, 0x01, 0x0d, 0x0b, 0x20, 0xd4, 0x01, 0x0d,
0x0c, 0x20, 0x10, 0x00, 0x01, 0x00, 0xa4, 0x03,
0x01, 0x03, 0xca, 0x03, 0x02, 0x03, 0xce, 0x03,
0x04, 0x03, 0xae, 0x02, 0x00, 0x03, 0xcc, 0x03,
0x03, 0x03, 0x08, 0xc4, 0x0d, 0x62, 0x02, 0x00,
0x62, 0x01, 0x00, 0x62, 0x00, 0x00, 0xd3, 0xcb,
0xd4, 0x11, 0xf4, 0xec, 0x08, 0x0e, 0x39, 0x46,
0x00, 0x00, 0x00, 0xdc, 0xcc, 0xd5, 0x11, 0xf4,
0xec, 0x08, 0x0e, 0x39, 0x46, 0x00, 0x00, 0x00,
0xdd, 0xcd, 0x62, 0x07, 0x00, 0x62, 0x06, 0x00,
0x62, 0x05, 0x00, 0x62, 0x04, 0x00, 0x62, 0x03,
0x00, 0xd4, 0x39, 0x46, 0x00, 0x00, 0x00, 0xb0,
0xec, 0x16, 0xd4, 0x98, 0x04, 0x1b, 0x00, 0x00,
0x00, 0xb0, 0xec, 0x0c, 0xdf, 0x11, 0x04, 0xf1,
0x00, 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x06,
0xce, 0xb6, 0xc4, 0x04, 0xc3, 0x0d, 0xf7, 0xc4,
0x05, 0x09, 0xc4, 0x06, 0xd3, 0xe0, 0x48, 0xc4,
0x07, 0x63, 0x07, 0x00, 0x07, 0xad, 0xec, 0x0f,
0x0a, 0x11, 0x64, 0x06, 0x00, 0x0e, 0xd3, 0xe1,
0x48, 0x11, 0x64, 0x07, 0x00, 0x0e, 0x63, 0x07,
0x00, 0x07, 0xad, 0x6a, 0xa6, 0x00, 0x00, 0x00,
0x62, 0x08, 0x00, 0x06, 0x11, 0xf4, 0xed, 0x0c,
0x71, 0x43, 0x32, 0x00, 0x00, 0x00, 0xc4, 0x08,
0x0e, 0xee, 0x05, 0x0e, 0xd3, 0xee, 0xf2, 0x63,
0x08, 0x00, 0x8e, 0x11, 0xed, 0x03, 0x0e, 0xb6,
0x11, 0x64, 0x08, 0x00, 0x0e, 0x63, 0x05, 0x00,
0xec, 0x0c, 0xc3, 0x0d, 0x11, 0x63, 0x08, 0x00,
0x21, 0x01, 0x00, 0xee, 0x06, 0xe2, 0x63, 0x08,
0x00, 0xf1, 0x11, 0x64, 0x03, 0x00, 0x0e, 0x63,
0x04, 0x00, 0x63, 0x08, 0x00, 0xa7, 0x6a, 0x2a,
0x01, 0x00, 0x00, 0x62, 0x09, 0x00, 0xd3, 0x63,
0x04, 0x00, 0x48, 0xc4, 0x09, 0x63, 0x06, 0x00,
0xec, 0x0a, 0x63, 0x09, 0x00, 0x8c, 0x11, 0x64,
0x09, 0x00, 0x0e, 0xd4, 0xec, 0x17, 0xd4, 0x43,
0xf2, 0x00, 0x00, 0x00, 0xd5, 0x63, 0x09, 0x00,
0x63, 0x04, 0x00, 0x24, 0x03, 0x00, 0x8c, 0x11,
0x64, 0x09, 0x00, 0x0e, 0x5f, 0x04, 0x00, 0x63,
0x03, 0x00, 0x63, 0x04, 0x00, 0x92, 0x64, 0x04,
0x00, 0x0b, 0x63, 0x09, 0x00, 0x4d, 0x41, 0x00,
0x00, 0x00, 0x0a, 0x4d, 0x3e, 0x00, 0x00, 0x00,
0x0a, 0x4d, 0x3f, 0x00, 0x00, 0x00, 0xf3, 0x0e,
0xee, 0x9e, 0x62, 0x0a, 0x00, 0x63, 0x07, 0x00,
0x43, 0xf2, 0x00, 0x00, 0x00, 0xd3, 0x24, 0x01,
0x00, 0xc4, 0x0a, 0x63, 0x05, 0x00, 0xec, 0x09,
0xc3, 0x0d, 0x11, 0x21, 0x00, 0x00, 0xee, 0x03,
0xe2, 0xf0, 0x11, 0x64, 0x03, 0x00, 0x0e, 0x6d,
0x8c, 0x00, 0x00, 0x00, 0x62, 0x0c, 0x00, 0x62,
0x0b, 0x00, 0x06, 0x11, 0xf4, 0xed, 0x13, 0x71,
0x43, 0x41, 0x00, 0x00, 0x00, 0xc4, 0x0b, 0x43,
0x6a, 0x00, 0x00, 0x00, 0xc4, 0x0c, 0x0e, 0xee,
0x10, 0x0e, 0x63, 0x0a, 0x00, 0x43, 0x6b, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x8c, 0xee, 0xe0,
0x63, 0x0c, 0x00, 0xed, 0x4e, 0x63, 0x06, 0x00,
0xec, 0x0a, 0x63, 0x0b, 0x00, 0x8c, 0x11, 0x64,
0x0b, 0x00, 0x0e, 0xd4, 0xec, 0x17, 0xd4, 0x43,
0xf2, 0x00, 0x00, 0x00, 0xd5, 0x63, 0x0b, 0x00,
0x63, 0x04, 0x00, 0x24, 0x03, 0x00, 0x8c, 0x11,
0x64, 0x0b, 0x00, 0x0e, 0x5f, 0x04, 0x00, 0x63,
0x03, 0x00, 0x63, 0x04, 0x00, 0x92, 0x64, 0x04,
0x00, 0x0b, 0x63, 0x0b, 0x00, 0x4d, 0x41, 0x00,
0x00, 0x00, 0x0a, 0x4d, 0x3e, 0x00, 0x00, 0x00,
0x0a, 0x4d, 0x3f, 0x00, 0x00, 0x00, 0xf3, 0x0e,
0xee, 0x83, 0x0e, 0x06, 0x6e, 0x0d, 0x00, 0x00,
0x00, 0x0e, 0xee, 0x1e, 0x6e, 0x05, 0x00, 0x00,
0x00, 0x30, 0x63, 0x0a, 0x00, 0x42, 0x06, 0x00,
0x00, 0x00, 0xec, 0x0d, 0x63, 0x0a, 0x00, 0x43,
0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x0e,
0x6f, 0x63, 0x03, 0x00, 0x63, 0x04, 0x00, 0x44,
0x32, 0x00, 0x00, 0x00, 0x63, 0x03, 0x00, 0x2f,
0xc1, 0x00, 0x28, 0xc1, 0x00, 0xcf, 0x28,
};

10 changes: 5 additions & 5 deletions builtin-array-fromasync.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
;(function(Array, TypeError, asyncIterator, defineProperty, iterator) {
;(function(Array, TypeError, Symbol·asyncIterator, Object·defineProperty, Symbol·iterator) {
"use strict" // result.length=i should throw if .length is not writable
return async function fromAsync(arrayLike, mapFn=undefined, thisArg=undefined) {
if (mapFn !== undefined && typeof mapFn !== "function") throw new TypeError("not a function")
let result, i = 0, isConstructor = typeof this === "function"
let sync = false, method = arrayLike[asyncIterator]
if (method == null) sync = true, method = arrayLike[iterator]
let sync = false, method = arrayLike[Symbol·asyncIterator]
if (method == null) sync = true, method = arrayLike[Symbol·iterator]
if (method == null) {
let {length} = arrayLike
length = +length || 0
Expand All @@ -13,7 +13,7 @@
let value = arrayLike[i]
if (sync) value = await value
if (mapFn) value = await mapFn.call(thisArg, value, i)
defineProperty(result, i++, {value, configurable: true, writable: true})
Object·defineProperty(result, i++, {value, configurable: true, writable: true})
}
} else {
const iter = method.call(arrayLike)
Expand All @@ -24,7 +24,7 @@
if (done) break
if (sync) value = await value
if (mapFn) value = await mapFn.call(thisArg, value, i)
defineProperty(result, i++, {value, configurable: true, writable: true})
Object·defineProperty(result, i++, {value, configurable: true, writable: true})
}
} finally {
if (iter.return) iter.return()
Expand Down
Loading