From 522984283b56b68582d606c76e4ca98c0baf9451 Mon Sep 17 00:00:00 2001 From: MDN Date: Tue, 15 Jun 2021 00:35:40 +0000 Subject: [CRON] sync translated content --- .../basic_concepts_behind_indexeddb/index.html | 213 --------------------- .../typed_array_invalid_arguments/index.html | 78 -------- 2 files changed, 291 deletions(-) delete mode 100644 files/ru/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html delete mode 100644 files/ru/web/javascript/reference/errors/typed_array_invalid_arguments/index.html (limited to 'files/ru/web') diff --git a/files/ru/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html b/files/ru/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html deleted file mode 100644 index 567f0a3d79..0000000000 --- a/files/ru/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: Basic concepts -slug: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB -translation_of: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB ---- -

{{DefaultAPISidebar("IndexedDB")}}

- -
-

IndexedDB обеспечивает возможность постоянного хранения данных посредством браузера пользователя. Поскольку это наделяет создаваемые web-приложения с расширенными возможностями независимостью от доступа к сети, такие приложения получают возможность работы как online, так и offline. IndexedDB полезна для приложений, хранящих большое количество данных (например, каталог DVD библиотеки проката) и не нуждающихся в постоянном подключении к Интернету (например, почтовые клиенты, перечни запланированного to-do и заметки на память).

-
- -

Об этом документе

- -

В этом введении рассматриваются основные концепции и термины в IndexedDB. Оно содержит общую картину и объясняет ключевые понятия.

- -

Оно может стать полезным для:

- - - -

Обзор IndexedDB

- -

IndexedDB позволяет сохранять и извлекать объекты, проиндексированные с помощью "ключа". Все манипуляции над базой данных происходят при помощи транзакций. Как и большинство решений для web-хранилищ, IndexedDB следует same-origin policy. Поэтому, если получить доступ к сохранённым данным в пределах домена можно, то вне его - нет.

- -

IndexedDB - асинхронное API, которое может быть использовано в большинстве контекстов, включая Web Workers. Раньше оно включало синхронную версию, для использования в web workers, но это было удалено из спецификации в связи с недостатком интереса внутри web-сообщества.

- -

Существует так же конкурирующая с IndexedDB спецификация, WebSQL Database, но W3C исключила её 18 ноября 2010. Хотя IndexedDB и WebSQL оба являются решением для хранилищ, они предоставляют различный функционал. WebSQL Database - реляционная система доступа к базам данных, когда IndexedDB - система индексированной таблицы.

- -

Big concepts

- -

Если у вас есть опыт работы с другими типами баз данных, то вы можете быть сбиты с толку в процессе работы с IndexedDB. Поэтому имейте в виду следующие важные понятия:

- - - -

Definitions

- -

This section defines and explains terms used in the IndexedDB API.

- -

Database

- -
-
database
-
A repository of information, typically comprising one or more object stores. Each database must have the following: -
    -
  • Name. This identifies the database within a specific origin and stays constant throughout its lifetime. The name can be any string value (including an empty string).
  • -
  • -

    Current version. When a database is first created, its version is the integer 1 if not specified otherwise. Each database can have only one version at any given time.

    -
  • -
-
-
durable
-
-

In Firefox, IndexedDB used to be durable, meaning that in a readwrite transaction {{domxref("IDBTransaction.oncomplete")}} was fired only when all data was guaranteed to have been flushed to disk.

- -

As of Firefox 40, IndexedDB transactions have relaxed durability guarantees to increase performance (see {{Bug("1112702")}}), which is the same behaviour as other IndexedDB-supporting browsers. In this case the {{Event("complete")}} event is fired after the OS has been told to write the data but potentially before that data has actually been flushed to disk. The event may thus be delivered quicker than before, however, there exists a small chance that the entire transaction will be lost if the OS crashes or there is a loss of system power before the data is flushed to disk. Since such catastrophic events are rare, most consumers should not need to concern themselves further.

- -
-

Note: In Firefox, if you wish to ensure durability for some reason (e.g. you're storing critical data that cannot be recomputed later) you can force a transaction to flush to disk before delivering the complete event by creating a transaction using the experimental (non-standard) readwriteflush mode (see {{domxref("IDBDatabase.transaction")}}.) This is currently experimental, and can only be used if the dom.indexedDB.experimental pref is set to true in about:config.

-
-
-
object store
-
-

The mechanism by which data is stored in the database. The object store persistently holds records, which are key-value pairs. Records within an object store are sorted according to the keys in an ascending order.

- -

Every object store must have a name that is unique within its database. The object store can optionally have a key generator and a key path. If the object store has a key path, it is using in-line keys; otherwise, it is using out-of-line keys.

- -

For the reference documentation on object store, see {{domxref("IDBObjectStore")}}.

-
-
version
-
When a database is first created, its version is the integer 1. Each database has one version at a time; a database can't exist in multiple versions at once. The only way to change the version is by opening it with a greater version than the current one. This will start a versionchange transaction and fire an upgradeneeded event. The only place where the schema of the database can be updated is inside the handler of that event.
-
Note: This definition describes the most recent specification, which is only implemented in up-to-date browsers. Old browsers implemented the now deprecated and removed IDBDatabase.setVersion() method.
-
database connection
-
An operation created by opening a database. A given database can have multiple connections at the same time.
-
transaction
-
-

An atomic set of data-access and data-modification operations on a particular database. It is how you interact with the data in a database. In fact, any reading or changing of data in the database must happen in a transaction.

- -

A database connection can have several active transactions associated with it at a time, so long as the writing transactions do not have overlapping scopes. The scope of transactions, which is defined at creation, determines which object stores the transaction can interact with and remains constant for the lifetime of the transaction. So, for example, if a database connection already has a writing transaction with a scope that just covers the flyingMonkey object store, you can start a second transaction with a scope of the unicornCentaur and unicornPegasus object stores. As for reading transactions, you can have several of them — even overlapping ones.

- -

Transactions are expected to be short-lived, so the browser can terminate a transaction that takes too long, in order to free up storage resources that the long-running transaction has locked. You can abort the transaction, which rolls back the changes made to the database in the transaction. And you don't even have to wait for the transaction to start or be active to abort it.

- -

The three modes of transactions are: readwrite, readonly, and versionchange. The only way to create and delete object stores and indexes is by using a versionchange transaction. To learn more about transaction types, see the reference article for IndexedDB.

- -

Because everything happens within a transaction, it is a very important concept in IndexedDB. To learn more about transactions, especially on how they relate to versioning, see {{domxref("IDBTransaction")}}, which also has reference documentation.

-
-
request
-
The operation by which reading and writing on a database is done. Every request represents one read or write operation.
-
index
-
-

An index is a specialized object store for looking up records in another object store, called the referenced object store. The index is a persistent key-value storage where the value part of its records is the key part of a record in the referenced object store. The records in an index are automatically populated whenever records in the referenced object store are inserted, updated, or deleted. Each record in an index can point to only one record in its referenced object store, but several indexes can reference the same object store. When the object store changes, all indexes that refer to the object store are automatically updated.

- -

Alternatively, you can also look up records in an object store using the key.

- -

To learn more on using indexes, see Using IndexedDB. For the reference documentation on index, see IDBKeyRange.

-
-
- -

Key and value

- -
-
key
-
-

A data value by which stored values are organized and retrieved in the object store. The object store can derive the key from one of three sources: a key generator, a key path, or an explicitly specified value. The key must be of a data type that has a number that is greater than the one before it. Each record in an object store must have a key that is unique within the same store, so you cannot have multiple records with the same key in a given object store.

- -

A key can be one of the following types: string, date, float, a binary blob, and array. For arrays, the key can range from an empty value to infinity. And you can include an array within an array.

- -

Alternatively, you can also look up records in an object store using the index.

-
-
key generator
-
A mechanism for producing new keys in an ordered sequence. If an object store does not have a key generator, then the application must provide keys for records being stored. Generators are not shared between stores. This is more a browser implementation detail, because in web development, you don't really create or access key generators.
-
in-line key
-
A key that is stored as part of the stored value. It is found using a key path. An in-line key can be generated using a generator. After the key has been generated, it can then be stored in the value using the key path or it can also be used as a key.
-
out-of-line key
-
A key that is stored separately from the value being stored.
-
key path
-
Defines where the browser should extract the key from in the object store or index. A valid key path can include one of the following: an empty string, a JavaScript identifier, or multiple JavaScript identifiers separated by periods or an array containing any of those. It cannot include spaces.
-
value
-
-

Each record has a value, which could include anything that can be expressed in JavaScript, including boolean, number, string, date, object, array, regexp, undefined, and null.

- -

When an object or array is stored, the properties and values in that object or array can also be anything that is a valid value.

- -

Blobs and files can be stored, cf. specification.

-
-
- -

Range and scope

- -
-
scope
-
The set of object stores and indexes to which a transaction applies. The scopes of read-only transactions can overlap and execute at the same time. On the other hand, the scopes of writing transactions cannot overlap. You can still start several transactions with the same scope at the same time, but they just queue up and execute one after another.
-
cursor
-
A mechanism for iterating over multiple records with a key range. The cursor has a source that indicates which index or object store it is iterating. It has a position within the range, and moves in a direction that is increasing or decreasing in the order of record keys. For the reference documentation on cursors, see {{domxref("IDBCursor")}}.
-
key range
-
-

A continuous interval over some data type used for keys. Records can be retrieved from object stores and indexes using keys or a range of keys. You can limit or filter the range using lower and upper bounds. For example, you can iterate over all values of a key between x and y.

- -

For the reference documentation on key range, see {{domxref("IDBKeyRange")}}.

-
-
- -

Limitations

- -

IndexedDB is designed to cover most cases that need client-side storage. However, it is not designed for a few cases like the following:

- - - -

In addition, be aware that browsers can wipe out the database, such as in the following conditions:

- - - -

The exact circumstances and browser capabilities change over time, but the general philosophy of the browser vendors is to make the best effort to keep the data when possible.

- -

Next steps

- -

With these big concepts under our belts, we can get to more concrete stuff. For a tutorial on how to use the API, see Using IndexedDB.

- -

See also

- - diff --git a/files/ru/web/javascript/reference/errors/typed_array_invalid_arguments/index.html b/files/ru/web/javascript/reference/errors/typed_array_invalid_arguments/index.html deleted file mode 100644 index 076743b50c..0000000000 --- a/files/ru/web/javascript/reference/errors/typed_array_invalid_arguments/index.html +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: 'TypeError: invalid arguments' -slug: Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments -tags: - - Error - - Errors - - JavaScript - - TypeError - - Ошибки -translation_of: Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments ---- -
{{jsSidebar("Errors")}}
- -

Сообщение

- -
TypeError: invalid arguments (Firefox)
- -

Тип ошибки

- -

{{jsxref("TypeError")}}

- -

Что не так?

- -

Конструкторы типизированных массивов требуют либо

- - - -

чтобы создать новый типизированный массив. Другие аргументы конструктора не создают допустимый типизированный массив.

- -

Примеры

- -

Типизированные массивы, например {{jsxref("Uint8Array")}}, не могут быть построены из строки. На самом деле строки вообще не могут быть в типизированных массивах.

- -
var ta = new Uint8Array("nope");
-// TypeError: invalid arguments
-
- -

Различные способы создания допустимого {{jsxref("Uint8Array")}}:

- -
 // From a length
-var uint8 = new Uint8Array(2);
-uint8[0] = 42;
-console.log(uint8[0]); // 42
-console.log(uint8.length); // 2
-console.log(uint8.BYTES_PER_ELEMENT); // 1
-
-// From an array
-var arr = new Uint8Array([21,31]);
-console.log(arr[1]); // 31
-
-// From another TypedArray
-var x = new Uint8Array([21, 31]);
-var y = new Uint8Array(x);
-console.log(y[0]); // 21
-
-// From an ArrayBuffer
-var buffer = new ArrayBuffer(8);
-var z = new Uint8Array(buffer, 1, 4);
-
-// From an iterable
-var iterable = function*(){ yield* [1,2,3]; }();
-var uint8 = new Uint8Array(iterable);
-// Uint8Array[1, 2, 3]
-
- -

Смотрите также

- - -- cgit v1.2.3-54-g00ecf