Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should passes when used properly', () => {
writeAsStringAsync('fileUri', 'content').then(fileInfo => {
(fileInfo: void);
// $ExpectError: check any
(fileInfo: number);
});
writeAsStringAsync('fileUri', 'content', { encoding: 'base64' });
writeAsStringAsync('fileUri', 'content', {
encoding: 'utf8',
});
});
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
writeAsStringAsync();
// $ExpectError: first argument must be a string
writeAsStringAsync(69);
// $ExpectError: second argument must be a string
writeAsStringAsync('', 69);
// $ExpectError: third argument must be an object
writeAsStringAsync('', '', 69);
// $ExpectError: 'abc' is missing in options
writeAsStringAsync('', '', { abc: 'test' });
writeAsStringAsync('', '', {
// $ExpectError: invalid value
encoding: 'кукусики',
});
});
});
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
writeAsStringAsync();
// $ExpectError: first argument must be a string
writeAsStringAsync(69);
// $ExpectError: second argument must be a string
writeAsStringAsync('', 69);
// $ExpectError: third argument must be an object
writeAsStringAsync('', '', 69);
// $ExpectError: 'abc' is missing in options
writeAsStringAsync('', '', { abc: 'test' });
writeAsStringAsync('', '', {
// $ExpectError: invalid value
encoding: 'кукусики',
});
});
});
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
writeAsStringAsync();
// $ExpectError: first argument must be a string
writeAsStringAsync(69);
// $ExpectError: second argument must be a string
writeAsStringAsync('', 69);
// $ExpectError: third argument must be an object
writeAsStringAsync('', '', 69);
// $ExpectError: 'abc' is missing in options
writeAsStringAsync('', '', { abc: 'test' });
writeAsStringAsync('', '', {
// $ExpectError: invalid value
encoding: 'кукусики',
});
});
});
it('should passes when used properly', () => {
writeAsStringAsync('fileUri', 'content').then(fileInfo => {
(fileInfo: void);
// $ExpectError: check any
(fileInfo: number);
});
writeAsStringAsync('fileUri', 'content', { encoding: 'base64' });
writeAsStringAsync('fileUri', 'content', {
encoding: 'utf8',
});
});
async enqueue (req) {
try {
await this.init()
await FileSystem.writeAsStringAsync(
`${this._path}/${generateFilename(this._resource)}`,
JSON.stringify({ ...req, retries: 0 })
)
this._truncate()
} catch (e) {
this._onerror(e)
}
}
const setItem = (key, value, callback) => withCallback(callback, async () => {
const { exists } = await FileSystem.getInfoAsync(baseFolder);
if (exists == false) {
await FileSystem.makeDirectoryAsync(baseFolder, {
intermediates: true
});
}
await FileSystem.writeAsStringAsync(pathForKey(key), value);
});
async function addLockToOldFilesDirectory(path) {
await FileSystem.writeAsStringAsync(path + LOCK_FILE_NAME, 'lock');
}
export async function migrateFilesFromLegacyDirectoryAsync(resolveConflict) {
withCallback(callback, async () => {
const { exists } = await FileSystem.getInfoAsync(baseFolder);
if (exists == false) {
await FileSystem.makeDirectoryAsync(baseFolder, {
intermediates: true,
});
}
await FileSystem.writeAsStringAsync(pathForKey(key), value);
});