FileSystemHandle: isSameEntry() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{securecontext_header}}{{APIRef("File System API")}}{{AvailableInWorkers}}

The **isSameEntry()** method of the {{domxref("FileSystemHandle")}} interface compares two {{domxref("FileSystemHandle", "handles")}} to see if the associated entries (either a file or directory) match.

Syntax

js-nolint
isSameEntry(fileSystemHandle)

Parameters

  • {{domxref("FileSystemHandle")}}
  • : The FileSystemHandle to match against the handle on which the method is

invoked.

Return value

A Promise that fulfills with a {{jsxref('Boolean')}}.

Examples

The following function compares a single entry with an array of entries, and returns a {{jsxref("Promise")}} that fulfills with a new array with any matching entries removed.

js
async function removeMatches(fileEntry, entriesArr) {
  const newArr = [];
  for (const entry of entriesArr) {
    if (!(await fileEntry.isSameEntry(entry))) {
      newArr.push(entry);
    }
  }
  return newArr;
}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • File System API
  • The File System Access API: simplifying access to local files