Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/node:buffer/Buffer/fillMfillmethod
buffer.Buffer.fill ``` `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or integer. If the resulting integer is greater than `255` (decimal), `buf` will be filled with `value & 255`. If the final write of a `fill()` operation falls on a multi-byte character, then only the bytes of that character that fit into `buf` are written: ```js import { Buffer } from 'node:buffer'; // Fill a `Buffer` with character that takes up two bytes in UTF-8. console.log(Buffer.allocUnsafe(5).fill('\u0222')); // Prints: ``` If `value` contains invalid characters, it is truncated; if no valid fill data remains, an exception is thrown: ```js import { Buffer } from 'node:buffer'; const buf = Buffer.allocUnsafe(5); console.log(buf.fill('a')); // Prints: console.log(buf.fill('aazz', 'hex')); // Prints: console.log(buf.fill('zz', 'hex')); // Throws an exception. ```" data-algolia-static="false" data-algolia-merged="false" data-type="Method">fill(value: string | number | Uint8ArrayArrayBufferLike>,offset?: number,end?: number,encoding?: BufferEncoding): this;Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled:import { Buffer } from 'node:buffer'; // Fill a `Buffer` with the ASCII character 'h'. const b = Buffer.allocUnsafe(50).fill('h'); console.log(b.toString()); // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh // Fill a buffer with empty string const c = Buffer.allocUnsafe(5).fill(''); console.log(c.fill('')); // Prints: value is coerced to a uint32 value if it is not a string, Buffer, or integer. If the resulting integer is greater than 255 (decimal), buf will be filled with value & 255.If the final write of a fill() operation falls on a multi-byte character, then only the bytes of that character that fit into buf are written:import { Buffer } from 'node:buffer'; // Fill a `Buffer` with character that takes up two bytes in UTF-8. console.log(Buffer.allocUnsafe(5).fill('\u0222')); // Prints: If value contains invalid characters, it is truncated; if no valid fill data remains, an exception is thrown:import { Buffer } from 'node:buffer'; const buf = Buffer.allocUnsafe(5); console.log(buf.fill('a')); // Prints: console.log(buf.fill('aazz', 'hex')); // Prints: console.log(buf.fill('zz', 'hex')); // Throws an exception. @param valueThe value with which to fill buf. Empty value (string, Uint8Array, Buffer) is coerced to 0.@param offsetNumber of bytes to skip before starting to fill buf.@param endWhere to stop filling buf (not inclusive).@param encodingThe encoding for value if value is a string.@returnsA reference to buf.fill(value: string | number | Uint8ArrayArrayBufferLike>,offset: number,encoding: BufferEncoding): this;fill(value: string | number | Uint8ArrayArrayBufferLike>,encoding: BufferEncoding): this;Referenced typesclass Uint8ArrayTArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.readonly [Symbol.toStringTag]: 'Uint8Array'readonly buffer: TArrayBufferThe ArrayBuffer instance referenced by the array.readonly byteLength: numberThe length in bytes of the array.readonly byteOffset: numberThe offset in bytes of the array.readonly BYTES_PER_ELEMENT: numberThe size in bytes of each element in the array.readonly length: numberThe length of the array.[Symbol.iterator](): ArrayIteratornumber>;at(index: number): undefined | number;Returns the item located at the specified index.@param indexThe zero-based index of the desired code unit. A negative index will count back from the last item.copyWithin(target: number,start: number,end?: number): this;Returns the this object after copying a section of the array identified by start and end to the same array starting at position target@param targetIf target is negative, it is treated as length+target where length is the length of the array.@param startIf start is negative, it is treated as length+start. If end is negative, it is treated as length+end.@param endIf not specified, length of the this object is used as its default value.entries(): ArrayIterator[number, number]>;Returns an array of key, value pairs for every entry in the arrayevery(predicate: (value: number, index: number, array: this) => unknown,thisArg?: any): boolean;Determines whether all the members of an array satisfy the specified test.@param predicateA function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.@param thisArgAn object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.fill(value: number,start?: number,end?: number): this;Changes all array elements from start to end index to a static value and returns the modified array@param valuevalue to fill array section with@param startindex to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array.@param endindex to stop filling the array at. If end is negative, it is treated as length+end.filter(predicate: (value: number, index: number, array: this) => any,thisArg?: any): Uint8ArrayArrayBuffer>;Returns the elements of an array that meet the condition specified in a callback function.@param predicateA function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param thisArgAn object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.find(predicate: (value: number, index: number, obj: this) => boolean,thisArg?: any): undefined | number;Returns the value of the first element in the array where predicate is true, and undefined otherwise.@param predicatefind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.@param thisArgIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.findIndex(predicate: (value: number, index: number, obj: this) => boolean,thisArg?: any): number;Returns the index of the first element in the array where predicate is true, and -1 otherwise.@param predicatefind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.@param thisArgIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.findLastS extends number>(predicate: (value: number, index: number, array: this) => value is S,thisArg?: any): undefined | S;Returns the value of the last element in the array where predicate is true, and undefined otherwise.@param predicatefindLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLast immediately returns that element value. Otherwise, findLast returns undefined.@param thisArgIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.findLast(predicate: (value: number, index: number, array: this) => unknown,thisArg?: any): undefined | number;findLastIndex(predicate: (value: number, index: number, array: this) => unknown,thisArg?: any): number;Returns the index of the last element in the array where predicate is true, and -1 otherwise.@param predicatefindLastIndex calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.@param thisArgIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.forEach(callbackfn: (value: number, index: number, array: this) => void,thisArg?: any): void;Performs the specified action for each element in an array.@param callbackfnA function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param thisArgAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.includes(searchElement: number,fromIndex?: number): boolean;Determines whether an array includes a certain element, returning true or false as appropriate.@param searchElementThe element to search for.@param fromIndexThe position in this array at which to begin searching for searchElement.indexOf(searchElement: number,fromIndex?: number): number;Returns the index of the first occurrence of a value in an array.@param searchElementThe value to locate in the array.@param fromIndexThe array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.join(separator?: string): string;Adds all the elements of an array separated by the specified separator string.@param separatorA string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.keys(): ArrayIteratornumber>;Returns an list of keys in the arraylastIndexOf(searchElement: number,fromIndex?: number): number;Returns the index of the last occurrence of a value in an array.@param searchElementThe value to locate in the array.@param fromIndexThe array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.map(callbackfn: (value: number, index: number, array: this) => number,thisArg?: any): Uint8ArrayArrayBuffer>;Calls a defined callback function on each element of an array, and returns an array that contains the results.@param callbackfnA function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param thisArgAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number): number;Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.@param callbackfnA function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number,initialValue: number): number;reduceU>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: this) => U,initialValue: U): U;Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.@param callbackfnA function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.@param initialValueIf initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number): number;Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.@param callbackfnA function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number,initialValue: number): number;reduceRightU>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: this) => U,initialValue: U): U;Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.@param callbackfnA function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.@param initialValueIf initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.reverse(): this;Reverses the elements in an Array.set(array: ArrayLikenumber>,offset?: number): void;Sets a value or an array of values.@param arrayA typed or untyped array of values to set.@param offsetThe index in the current array at which the values are to be written.setFromBase64(base64: string,offset?: number): { read: number; written: number };Set the contents of the Uint8Array from a base64 encoded string@param base64The base64 encoded string to decode into the array@param offsetOptional starting index to begin setting the decoded bytes (default: 0)setFromHex(hex: string): { read: number; written: number };Set the contents of the Uint8Array from a hex encoded string@param hexThe hex encoded string to decode into the array. The string must have an even number of characters, be valid hexadecimal characters and contain no whitespace.slice(start?: number,end?: number): Uint8ArrayArrayBuffer>;Returns a section of an array.@param startThe beginning of the specified portion of the array.@param endThe end of the specified portion of the array. This is exclusive of the element at the index 'end'.some(predicate: (value: number, index: number, array: this) => unknown,thisArg?: any): boolean;Determines whether the specified callback function returns true for any element of an array.@param predicateA function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array.@param thisArgAn object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.sort(compareFn?: (a: number, b: number) => number): this;Sorts an array.@param compareFnFunction used to determine the order of the elements. It is expected to return a negative value if first argument is less than second argument, zero if they're equal and a positive value otherwise. If omitted, the elements are sorted in ascending order.[11,2,22,1].sort((a, b) => a - b) subarray(begin?: number,end?: number): Uint8ArrayTArrayBuffer>;Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive.@param beginThe index of the beginning of the array.@param endThe index of the end of the array.toBase64(options?: { alphabet: 'base64' | 'base64url'; omitPadding: boolean }): string;Convert the Uint8Array to a base64 encoded string@returnsThe base64 encoded string representation of the Uint8ArraytoHex(): string;Convert the Uint8Array to a hex encoded string@returnsThe hex encoded string representation of the Uint8ArraytoLocaleString(): string;Converts a number to a string by using the current locale.toLocaleString(locales: string | string[],options?: NumberFormatOptions): string;toReversed(): Uint8ArrayArrayBuffer>;Copies the array and returns the copy with the elements in reverse order.toSorted(compareFn?: (a: number, b: number) => number): Uint8ArrayArrayBuffer>;Copies and sorts the array.@param compareFnFunction used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending order.const myNums = Uint8Array.from([11, 2, 22, 1]); myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] toString(): string;Returns a string representation of an array.valueOf(): this;Returns the primitive value of the specified object.values(): ArrayIteratornumber>;Returns an list of values in the arraywith(index: number,value: number): Uint8ArrayArrayBuffer>;Copies the array and inserts the given number at the provided index.@param indexThe index of the value to overwrite. If the index is negative, then it replaces from the end of the array.@param valueThe value to insert into the copied array.@returnsA copy of the original array with the inserted value.Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San FranciscoWe're hiring →智能索引记录
-
2026-03-03 02:51:04
综合导航
成功
标题:æ°ç¦çæ¼é³_æ°ç¦çææ_æ°ç¦çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æ°ç¦é¢é,ä»ç»æ°ç¦,æ°ç¦çæ¼é³,æ°ç¦æ¯
-
2026-03-02 11:02:41
综合导航
成功
标题:National Cancer Institute: Smokefree - Case Study ICF Next
简介:The nation’s first and largest data-driven program to help p
-
2026-03-02 19:33:50
综合导航
成功
标题:宝宝口腔溃疡怎么治才好 - 云大夫
简介:如果宝宝发生创伤性的溃疡,主要给与口腔局部的消炎处理,比如注意口腔卫生,另外给与表皮因子来促进溃疡愈合。如果是手足口病、
-
2026-03-02 10:56:34
综合导航
成功
标题:åè¡çæ¼é³_åè¡çææ_åè¡çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½åè¡é¢é,ä»ç»åè¡,åè¡çæ¼é³,åè¡æ¯
-
2026-03-02 19:40:55
游戏娱乐
成功
标题:保卫钻石宝藏2v1.2,保卫钻石宝藏2v1.2小游戏,4399小游戏 www.4399.com
简介:保卫钻石宝藏2v1.2在线玩,保卫钻石宝藏2v1.2下载, 保卫钻石宝藏2v1.2攻略秘籍.更多保卫钻石宝藏2v1.2游
-
2026-03-03 06:33:22
综合导航
成功
标题:LG EXPANDS AI REACH TO RUSSIA IN PARTNERSHIP WITH YANDEX LG Global
简介:As part of its vision to make artificial intelligence in the
-
2026-03-02 21:39:08
综合导航
成功
标题:æéçæ¼é³_æéçææ_æéçç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æéé¢é,ä»ç»æé,æéçæ¼é³,æéæ¯
-
2026-03-03 05:15:01
教育培训
成功
标题:[精华]关于秋游的作文15篇
简介:在平凡的学习、工作、生活中,大家都接触过作文吧,借助作文可以提高我们的语言组织能力。那么你知道一篇好的作文该怎么写吗?以
-
2026-03-03 01:04:36
游戏娱乐
成功
标题:吸血鬼:化装舞会 游戏截图截图_吸血鬼:化装舞会 游戏截图壁纸_吸血鬼:化装舞会 游戏截图图片_3DM单机
简介:吸血鬼:化装舞会 游戏截图截图_吸血鬼:化装舞会 游戏截图壁纸_吸血鬼:化装舞会 游戏截图图片_3DM单机
-
2026-03-03 05:45:50
综合导航
成功
标题:Texas In-House Lawyers Lag Behind Nation in AI Adoption. Here's Why Law.com
简介:Texas in-house attorneys are adopting AI and predictive anal
-
2026-03-02 21:40:36
综合导航
成功
标题:è¦æ£çæ¼é³_è¦æ£çææ_è¦æ£çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½è¦æ£é¢é,ä»ç»è¦æ£,è¦æ£çæ¼é³,è¦æ£æ¯
-
2026-03-02 10:58:59
综合导航
成功
标题:AI智能索引
简介:clswun鐨勪釜浜鸿祫鏂 ,瀛︽硶缃 /> <title>clswun鐨勪釜浜鸿祫鏂 - 瀛︽硶缃慄/title><
-
2026-03-03 06:26:14
教育培训
成功
标题:2026年中国腰斧行业市场规模及投资前景预测分析报告 - 豆丁网
简介:豆丁网是面向全球的中文社会化阅读分享平台,拥有商业,教育,研究报告,行业资料,学术论文,认证考试,星座,心理学等数亿实用
-
2026-03-02 20:59:22
职场办公
成功
标题:欧洲卡车模拟2联机存档制作教程_3DM单机
简介:准备工作:首先需要准备一个联机专用的存档,如果是制作来跟几个基友一起跑的,可以用自己存档。联机专用的存档,需要车库全开,
-
2026-03-02 21:16:19
博客创作
成功
标题:天狂传说之斗罗大陆1最新章节_天狂传说之斗罗大陆1小说免费全文阅读_恋上你看书网
简介:天狂传说之斗罗大陆,天狂传说之斗罗大陆小说阅读,玄幻魔法类型小说,天狂传说之斗罗大陆由作家懒人创作,小狂这次被淫神送到了
-
2026-03-02 20:55:47
综合导航
成功
标题:When football stars become “on-chain assets”, how to play the popular Football.Fun?Recommended Articles Bee Network
简介:Recently, a Web 3 soccer fantasy game called Football.Fun we
-
2026-03-03 05:59:25
综合导航
成功
标题:Pet Makeup Master - Online Unblocked Game
简介:Pet Makeup Master is a casual game. Get up close and persona
-
2026-03-02 21:00:36
综合导航
成功
标题:æä»çæ¼é³_æä»çææ_æä»çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æä»é¢é,ä»ç»æä»,æä»çæ¼é³,æä»æ¯
-
2026-03-03 05:57:55
数码科技
成功
标题:本诗仙拥兵百万,你让我自重?第175章 康王世子府!_本诗仙拥兵百万,你让我自重?_一头好人_十二小说网_规则类怪谈扮演指南
简介:本诗仙拥兵百万,你让我自重?最新章节第175章 康王世子府!出自一头好人的作品本诗仙拥兵百万,你让我自重?最新章节每天第
-
2026-03-03 01:03:55
教育培训
成功
标题:新王牌培优_上海春季补习班_初中高中课外辅导补课培训机构
简介:新王牌创立于2005年,拥有一支强大的名师天团,定位培优,学生都来自重点中学,采用分层授课,小班教学,支持按月收费,成就
-
2026-03-03 06:59:58
游戏娱乐
成功
标题:602《武易》结婚详解 - 游戏攻略 - 602游戏平台 - 做玩家喜爱、信任的游戏平台!cccS
简介:或许很多的游戏玩家都属于宅男宅女的行列,在生活中很少能够有什么艳遇,如今在武易中你不用再担心艳遇的几率少了,因为在武易游
-
2026-03-03 01:06:23
图片素材
成功
标题:当你不再爱我的时候最新章节_当你不再爱我的时候小说免费全文阅读_恋上你看书网
简介:如茶似火的青春里,低调而果断的做事风格让她更加成熟稳重。爱情里的她将无微不至的关怀送去远方,时时刻刻忘不了的人在自己最关
-
2026-03-03 03:16:52
综合导航
成功
标题:what rear addons flow w/toms sides? [Archive] - Toyota MR2 Message Board
简介:i have toms sideskirts and im having trouble finding any rea
-
2026-03-02 19:41:23
新闻资讯
成功
标题:第92页 - 34楼
简介:34楼是一家资源网站,主要为用户提供赚钱资源,谈天说地,小吃美食,历史相关,游戏资讯,信用卡,站长资讯,社交电商,积分,
-
2026-03-03 06:32:01
综合导航
成功
标题:거산고구마 상품 후기 달콤하고 쫀득해요
简介:거산고구마 자연 그대로의 달콤함, 신선한 맛으로 고객 만족이 높아요
-
2026-03-02 20:51:17
综合导航
成功
标题:那个扮男装的网恋徒弟叫什么最新章节_那个扮男装的网恋徒弟叫什么小说免费全文阅读_恋上你看书网
简介:在朋友的请求下,盛南崢收了一个男徒弟,虽然玩着奶妈,但是却有一颗输出的心!倒是个...可爱的男孩子。渐渐地,好像开始不一
-
2026-03-03 02:46:22
综合导航
成功
标题:廿£çæ¼é³_廿£çææ_廿£çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½å»æ£é¢é,ä»ç»å»æ£,廿£çæ¼é³,廿£æ¯
-
2026-03-03 01:03:05
综合导航
成功
标题:脚踏一星什么意思?最新章节_第三十六章 五源战决第1页_脚踏一星什么意思?免费章节_恋上你看书网
简介:第三十六章 五源战决第1页_脚踏一星什么意思?_独孤柳_恋上你看书网
-
2026-03-02 10:45:21
图片素材
成功
标题:幸福的作文400字 描写幸福的作文 关于幸福的作文-作文网
简介:作文网精选关于幸福的400字作文,包含幸福的作文素材,关于幸福的作文题目,以幸福为话题的400字作文大全,作文网原创名师
-
2026-03-02 21:39:09
综合导航
成功
标题:ç«é³çæ¼é³_ç«é³çææ_ç«é³çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½ç«é³é¢é,ä»ç»ç«é³,ç«é³çæ¼é³,ç«é³æ¯