MCPcopy
hub / github.com/discordjs/discord.js / map

Method map

packages/collection/src/collection.ts:510–518  ·  view source on GitHub ↗
(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown)

Source from the content-addressed store, hash-verified

508 thisArg: This,
509 ): NewValue[];
510 public map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown): NewValue[] {
511 if (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);
512 if (thisArg !== undefined) fn = fn.bind(thisArg);
513 const iter = this.entries();
514 return Array.from({ length: this.size }, (): NewValue => {
515 const [key, value] = iter.next().value!;
516 return fn(value, key, this);
517 });
518 }
519
520 /**
521 * Maps each item to another value into a collection. Identical in behavior to

Callers 15

flatMapMethod · 0.95
index.tsFile · 0.80
collection.test.tsFile · 0.80
escapeMarkdownFunction · 0.80
listCallbackFunction · 0.80
emailFunction · 0.80
withFilesFunction · 0.80
constructorMethod · 0.80
addComponentsMethod · 0.80
addLabelComponentsMethod · 0.80

Calls 2

nextMethod · 0.80
fromMethod · 0.45

Tested by 1