UNPKG

kura

Version:

The FileSystem API abstraction library.

41 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRange = exports.createFileEntry = exports.createDirectoryEntry = exports.countSlash = void 0; const FileSystemConstants_1 = require("../FileSystemConstants"); const IdbDirectoryEntry_1 = require("./IdbDirectoryEntry"); const IdbFileEntry_1 = require("./IdbFileEntry"); const DIR_OPEN_BOUND = String.fromCharCode(FileSystemConstants_1.DIR_SEPARATOR.charCodeAt(0) + 1); function countSlash(path) { let result = 0; for (let i = 0, end = path.length; i < end; i++) { if (path[i] === FileSystemConstants_1.DIR_SEPARATOR) { result++; } } return result; } exports.countSlash = countSlash; function createDirectoryEntry(accessor, obj) { return new IdbDirectoryEntry_1.IdbDirectoryEntry({ accessor: accessor, ...obj, }); } exports.createDirectoryEntry = createDirectoryEntry; function createFileEntry(accessor, obj) { return new IdbFileEntry_1.IdbFileEntry({ accessor: accessor, ...obj, }); } exports.createFileEntry = createFileEntry; function getRange(fullPath) { if (fullPath === FileSystemConstants_1.DIR_SEPARATOR) { return IDBKeyRange.bound(FileSystemConstants_1.DIR_SEPARATOR, DIR_OPEN_BOUND, false, true); } else { return IDBKeyRange.bound(fullPath + FileSystemConstants_1.DIR_SEPARATOR, fullPath + DIR_OPEN_BOUND, false, true); } } exports.getRange = getRange; //# sourceMappingURL=IdbUtil.js.map