Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 5x 99x 5x 99x 99x 99x 5x 5x 57x 57x 5x 23x 4x 5x 7x 5x 5x | import type { CoreFsaContext } from './types';
/**
* Creates a new {@link CoreFsaContext}.
*/
export const ctx = (partial: Partial<CoreFsaContext> = {}): CoreFsaContext => {
return {
separator: '/',
syncHandleAllowed: false,
mode: 'read',
...partial,
};
};
export const basename = (path: string, separator: string) => {
if (path[path.length - 1] === separator) path = path.slice(0, -1);
const lastSlashIndex = path.lastIndexOf(separator);
return lastSlashIndex === -1 ? path : path.slice(lastSlashIndex + 1);
};
const nameRegex = /^(\.{1,2})$|[\/\\]/;
export const assertName = (name: string, method: string, klass: string) => {
const isInvalid = !name || nameRegex.test(name);
Iif (isInvalid) throw new TypeError(`Failed to execute '${method}' on '${klass}': Name is not allowed.`);
};
export const assertCanWrite = (mode: 'read' | 'readwrite') => {
if (mode !== 'readwrite')
throw new DOMException(
'The request is not allowed by the user agent or the platform in the current context.',
'NotAllowedError',
);
};
export const newNotFoundError = () =>
new DOMException(
'A requested file or directory could not be found at the time an operation was processed.',
'NotFoundError',
);
export const newTypeMismatchError = () =>
new DOMException('The path supplied exists, but was not an entry of requested type.', 'TypeMismatchError');
export const newNotAllowedError = () => new DOMException('Permission not granted.', 'NotAllowedError');
|