Skip to content

Commit 6f97180

Browse files
authored
Update article.md till summery
1 parent 7a75b6c commit 6f97180

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

4-binary/01-arraybuffer-binary-arrays/article.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -187,62 +187,64 @@ alert(uint8array[1]); // 1
187187

188188
## متدهای TypedArray
189189

190-
`TypedArray` has regular `Array` methods, with notable exceptions.
190+
متدهای `TypedArray` مانند آرایه‌های معمولی می‌باشد ولی استثناهای قابل توجهی نیز وجود دارد.
191191

192-
We can iterate, `map`, `slice`, `find`, `reduce` etc.
192+
ما می‌توانیم `map`، `slice`، `find`، `reduce` و غیره را پیمایش کنیم.
193193

194-
There are few things we can't do though:
194+
هرچند، تعداد کمی کار وجود دارد که ما نمی‌توانیم انجام دهیم:
195195

196-
- No `splice` -- we can't "delete" a value, because typed arrays are views on a buffer, and these are fixed, contiguous areas of memory. All we can do is to assign a zero.
197-
- No `concat` method.
196+
- بدون `splice` -- ما نمی‌توانیم یک مقدار را "حذف" کنیم، زیرا آرایه‌های typed، درواقع viewهایی روی یک بافر هستند که ناحیه‌هایی ثابت و پیوسته روی حافظه می‌باشند. تنها کاری که ما می‌توانیم انجام دهیم تخصیص یک صفر است.
198197

199-
There are two additional methods:
198+
- بدون متد `concat`
200199

201-
- `arr.set(fromArr, [offset])` copies all elements from `fromArr` to the `arr`, starting at position `offset` (0 by default).
202-
- `arr.subarray([begin, end])` creates a new view of the same type from `begin` to `end` (exclusive). That's similar to `slice` method (that's also supported), but doesn't copy anything -- just creates a new view, to operate on the given piece of data.
200+
دو ممتد اضافی نیز وجود دارد:
203201

204-
These methods allow us to copy typed arrays, mix them, create new arrays from existing ones, and so on.
202+
- متد `arr.set(fromArr, [offset])` تمام اعضای `fromArr` را در `arr` کپی می‌کند، که این کپی کردن از محل `offset` شروع می‌شود.(حالت پیش‌فرض آن 0 است.)
203+
204+
- متد `arr.subarray([begin, end])` یک view جدید از همان نوع را از `begin` تا `end` می‌سازد(انحصاری). این متد مانند متد `slice` است(آن متد نیز پشتیبانی می‌شود.) ولی چیزی را کپی نمی‌کند -- فقط یک view جدید می‌سازد که روی داده‌های داده شده، عمملیات انجام دهد.
205+
206+
این متدها به ما اجازه می‌دهد که آرایه‌های typed را کپی کنیم، آن‌ها را با هم ترکیب کنیم، آرایه‌های جدید از آرایه‌های موجود بسازیم، و به همین ترتیب.
205207

206208

207209

208210
## DataView
209211

210-
[DataView](mdn:/JavaScript/Reference/Global_Objects/DataView) is a special super-flexible "untyped" view over `ArrayBuffer`. It allows to access the data on any offset in any format.
212+
یک [DataView](mdn:/JavaScript/Reference/Global_Objects/DataView) یک view خاص فوق‌العاده انعطاف‌پذیر "untyped" روی `ArrayBuffer` است. DataView اجازه می‌هد که در هر offset و در هر فرمتی به داده‌ها دسترسی داشته باشیم.
211213

212-
- For typed arrays, the constructor dictates what the format is. The whole array is supposed to be uniform. The i-th number is `arr[i]`.
213-
- With `DataView` we access the data with methods like `.getUint8(i)` or `.getUint16(i)`. We choose the format at method call time instead of the construction time.
214+
- برای آرایه‌های typed، سازنده فرمت را مشخص می‌کند. کل آرایه قرار است یکنواخت باشد. عدد iام، `arr[i]` است.
214215

215-
The syntax:
216+
- با `DataView`، ما با متدهایی مانند `.getUint8(i)` یا `.getUint16(i)` به داده دسترسی پیدا می‌کنیم. ما فرمت را بجای هنگام ساخت، هنگام فراخوانی متد انتخاب می‌کنیم.
216217

218+
سینتکس:
217219
```js
218220
new DataView(buffer, [byteOffset], [byteLength])
219221
```
220222

221-
- **`buffer`** -- the underlying `ArrayBuffer`. Unlike typed arrays, `DataView` doesn't create a buffer on its own. We need to have it ready.
222-
- **`byteOffset`** -- the starting byte position of the view (by default 0).
223-
- **`byteLength`** -- the byte length of the view (by default till the end of `buffer`).
223+
- **`buffer`** -- بافر مخصوص خودش را نمی‌سازد. ما باید آن را آماده داشته باشیم typed برخلاف آرایه‌های `DataView` .دربرگیرنده `ArrayBuffer`
224+
- **`byteOffset`** -- (حالت پیش‌فرض 0 می‌باشد)view محل بایت شروع‌کننده‌ی
225+
- **`byteLength`** -- (حالت پیش‌فرض تا انتهای بافر می‌باشد)view طول بایت‌های
224226

225-
For instance, here we extract numbers in different formats from the same buffer:
227+
برای نمونه، در اینجا ما اعداد یک بافر یکسان را در فرمت‌های مختلف استخراج کرده‌ایم:
226228

227229
```js run
228-
// binary array of 4 bytes, all have the maximal value 255
230+
// آرایه‌های دودویی 4 بایتی، که حداکثر مقدار همه‌ی آن‌ها 255 است
229231
let buffer = new Uint8Array([255, 255, 255, 255]).buffer;
230232
231233
let dataView = new DataView(buffer);
232234
233-
// get 8-bit number at offset 0
235+
// صفر offset دریافت یک عدد 8 بیتی در
234236
alert( dataView.getUint8(0) ); // 255
235237
236-
// now get 16-bit number at offset 0, it consists of 2 bytes, together interpreted as 65535
237-
alert( dataView.getUint16(0) ); // 65535 (biggest 16-bit unsigned int)
238+
// صفر، این عدد از دو بایت تشکیل شده است که با هم 65535 را نشان می‌دهند offset حالا دریافت یک عدد 16 بیتی در
239+
alert( dataView.getUint16(0) ); // 65535 (بزرگترین عدد صحیح بدون‌علامت 16 بیتی)
238240
239-
// get 32-bit number at offset 0
240-
alert( dataView.getUint32(0) ); // 4294967295 (biggest 32-bit unsigned int)
241+
// صفر offset دریافت یک عدد 32 بیتی در
242+
alert( dataView.getUint32(0) ); // 4294967295 (بزرگترین عدد صحیح بدون‌علامت 32 بیتی)
241243
242-
dataView.setUint32(0, 0); // set 4-byte number to zero, thus setting all bytes to 0
244+
dataView.setUint32(0, 0); // صفر قرار دادن یک عدد 4 بایتی، در نتیجه همه بایت‌ها را صفر می‌کنیم
243245
```
244246

245-
`DataView` is great when we store mixed-format data in the same buffer. For example, when we store a sequence of pairs (16-bit integer, 32-bit float), `DataView` allows to access them easily.
247+
هنگامی که می‌خواهیم داده‌هایی با فرمت‌های درهم و برهم را در یک بافر ذخیره کنیم، `DataView` عالی است. به عنوان مثال، هنگامی که دنباله‌ای از جفت‌های(عدد صحیح 16 بیتی، عدد اعشاری 32 بیتی) را ذخیره می‌کنیم، `DataView` به آسانی اجازه دسترسی به آن‌ها را می‌دهد.
246248

247249
## Summary
248250

0 commit comments

Comments
 (0)