Initial import with skill sheet working
This commit is contained in:
1
node_modules/@seald-io/nedb/browser-version/lib/byline.js
generated
vendored
Normal file
1
node_modules/@seald-io/nedb/browser-version/lib/byline.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = {}
|
||||
76
node_modules/@seald-io/nedb/browser-version/lib/customUtils.js
generated
vendored
Executable file
76
node_modules/@seald-io/nedb/browser-version/lib/customUtils.js
generated
vendored
Executable file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Utility functions that need to be reimplemented for each environment.
|
||||
* This is the version for the browser & React-Native
|
||||
* @module customUtilsBrowser
|
||||
* @private
|
||||
*/
|
||||
|
||||
/**
|
||||
* Taken from the crypto-browserify module
|
||||
* https://github.com/dominictarr/crypto-browserify
|
||||
* NOTE: Math.random() does not guarantee "cryptographic quality" but we actually don't need it
|
||||
* @param {number} size in bytes
|
||||
* @return {Array<number>}
|
||||
*/
|
||||
const randomBytes = size => {
|
||||
const bytes = new Array(size)
|
||||
|
||||
for (let i = 0, r; i < size; i++) {
|
||||
if ((i & 0x03) === 0) r = Math.random() * 0x100000000
|
||||
bytes[i] = r >>> ((i & 0x03) << 3) & 0xff
|
||||
}
|
||||
|
||||
return bytes
|
||||
}
|
||||
|
||||
/**
|
||||
* Taken from the base64-js module
|
||||
* https://github.com/beatgammit/base64-js/
|
||||
* @param {Array} uint8
|
||||
* @return {string}
|
||||
*/
|
||||
const byteArrayToBase64 = uint8 => {
|
||||
const lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||
const extraBytes = uint8.length % 3 // if we have 1 byte left, pad 2 bytes
|
||||
let output = ''
|
||||
let temp
|
||||
|
||||
const tripletToBase64 = num => lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
|
||||
|
||||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||||
for (let i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
||||
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
||||
output += tripletToBase64(temp)
|
||||
}
|
||||
|
||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||
if (extraBytes === 1) {
|
||||
temp = uint8[uint8.length - 1]
|
||||
output += lookup[temp >> 2]
|
||||
output += lookup[(temp << 4) & 0x3F]
|
||||
output += '=='
|
||||
} else if (extraBytes === 2) {
|
||||
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
||||
output += lookup[temp >> 10]
|
||||
output += lookup[(temp >> 4) & 0x3F]
|
||||
output += lookup[(temp << 2) & 0x3F]
|
||||
output += '='
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random alphanumerical string of length len
|
||||
* There is a very small probability (less than 1/1,000,000) for the length to be less than len
|
||||
* (il the base64 conversion yields too many pluses and slashes) but
|
||||
* that's not an issue here
|
||||
* The probability of a collision is extremely small (need 3*10^12 documents to have one chance in a million of a collision)
|
||||
* See http://en.wikipedia.org/wiki/Birthday_problem
|
||||
* @param {number} len
|
||||
* @return {string}
|
||||
* @alias module:customUtilsNode.uid
|
||||
*/
|
||||
const uid = len => byteArrayToBase64(randomBytes(Math.ceil(Math.max(8, len * 2)))).replace(/[+/]/g, '').slice(0, len)
|
||||
|
||||
module.exports.uid = uid
|
||||
191
node_modules/@seald-io/nedb/browser-version/lib/storage.browser.js
generated
vendored
Executable file
191
node_modules/@seald-io/nedb/browser-version/lib/storage.browser.js
generated
vendored
Executable file
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* Way data is stored for this database
|
||||
*
|
||||
* This version is the browser version and uses [localforage]{@link https://github.com/localForage/localForage} which chooses the best option depending on user browser (IndexedDB then WebSQL then localStorage).
|
||||
* @module storageBrowser
|
||||
* @see module:storage
|
||||
* @see module:storageReactNative
|
||||
* @private
|
||||
*/
|
||||
|
||||
const localforage = require('localforage')
|
||||
|
||||
// Configure localforage to display NeDB name for now. Would be a good idea to let user use his own app name
|
||||
const store = localforage.createInstance({
|
||||
name: 'NeDB',
|
||||
storeName: 'nedbdata'
|
||||
})
|
||||
|
||||
/**
|
||||
* Returns Promise<true> if file exists.
|
||||
*
|
||||
* @param {string} file
|
||||
* @return {Promise<boolean>}
|
||||
* @async
|
||||
* @alias module:storageBrowser.existsAsync
|
||||
*/
|
||||
const existsAsync = async file => {
|
||||
try {
|
||||
const value = await store.getItem(file)
|
||||
if (value !== null) return true // Even if value is undefined, localforage returns null
|
||||
return false
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the item from one path to another.
|
||||
* @param {string} oldPath
|
||||
* @param {string} newPath
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageBrowser.renameAsync
|
||||
* @async
|
||||
*/
|
||||
const renameAsync = async (oldPath, newPath) => {
|
||||
try {
|
||||
const value = await store.getItem(oldPath)
|
||||
if (value === null) await store.removeItem(newPath)
|
||||
else {
|
||||
await store.setItem(newPath, value)
|
||||
await store.removeItem(oldPath)
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('An error happened while renaming, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the item at given path.
|
||||
* @param {string} file
|
||||
* @param {string} data
|
||||
* @param {object} [options]
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageBrowser.writeFileAsync
|
||||
* @async
|
||||
*/
|
||||
const writeFileAsync = async (file, data, options) => {
|
||||
// Options do not matter in browser setup
|
||||
try {
|
||||
await store.setItem(file, data)
|
||||
} catch (error) {
|
||||
console.warn('An error happened while writing, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to the item at given path.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {string} toAppend
|
||||
* @param {object} [options]
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageBrowser.appendFileAsync
|
||||
* @async
|
||||
*/
|
||||
const appendFileAsync = async (filename, toAppend, options) => {
|
||||
// Options do not matter in browser setup
|
||||
try {
|
||||
const contents = (await store.getItem(filename)) || ''
|
||||
await store.setItem(filename, contents + toAppend)
|
||||
} catch (error) {
|
||||
console.warn('An error happened appending to file writing, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data at given path.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {object} [options]
|
||||
* @return {Promise<Buffer>}
|
||||
* @alias module:storageBrowser.readFileAsync
|
||||
* @async
|
||||
*/
|
||||
const readFileAsync = async (filename, options) => {
|
||||
try {
|
||||
return (await store.getItem(filename)) || ''
|
||||
} catch (error) {
|
||||
console.warn('An error happened while reading, skip')
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageBrowser.unlink}.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @return {Promise<void>}
|
||||
* @async
|
||||
* @alias module:storageBrowser.unlink
|
||||
*/
|
||||
const unlinkAsync = async filename => {
|
||||
try {
|
||||
await store.removeItem(filename)
|
||||
} catch (error) {
|
||||
console.warn('An error happened while unlinking, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.mkdirAsync}, nothing to do, no directories will be used on the browser.
|
||||
* @function
|
||||
* @param {string} path
|
||||
* @param {object} [options]
|
||||
* @return {Promise<void|string>}
|
||||
* @alias module:storageBrowser.mkdirAsync
|
||||
* @async
|
||||
*/
|
||||
const mkdirAsync = (path, options) => Promise.resolve()
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.ensureParentDirectoryExistsAsync}, nothing to do, no directories will be used on the browser.
|
||||
* @function
|
||||
* @param {string} file
|
||||
* @param {number} [mode]
|
||||
* @return {Promise<void|string>}
|
||||
* @alias module:storageBrowser.ensureParentDirectoryExistsAsync
|
||||
* @async
|
||||
*/
|
||||
const ensureParentDirectoryExistsAsync = async (file, mode) => Promise.resolve()
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.ensureDatafileIntegrityAsync}, nothing to do, no data corruption possible in the browser.
|
||||
* @param {string} filename
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageBrowser.ensureDatafileIntegrityAsync
|
||||
*/
|
||||
const ensureDatafileIntegrityAsync = (filename) => Promise.resolve()
|
||||
|
||||
/**
|
||||
* Fully write or rewrite the datafile, immune to crashes during the write operation (data will not be lost)
|
||||
* * @param {string} filename
|
||||
* @param {string[]} lines
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageBrowser.crashSafeWriteFileLinesAsync
|
||||
*/
|
||||
const crashSafeWriteFileLinesAsync = async (filename, lines) => {
|
||||
lines.push('') // Add final new line
|
||||
await writeFileAsync(filename, lines.join('\n'))
|
||||
}
|
||||
|
||||
// Interface
|
||||
module.exports.existsAsync = existsAsync
|
||||
|
||||
module.exports.renameAsync = renameAsync
|
||||
|
||||
module.exports.writeFileAsync = writeFileAsync
|
||||
|
||||
module.exports.crashSafeWriteFileLinesAsync = crashSafeWriteFileLinesAsync
|
||||
|
||||
module.exports.appendFileAsync = appendFileAsync
|
||||
|
||||
module.exports.readFileAsync = readFileAsync
|
||||
|
||||
module.exports.unlinkAsync = unlinkAsync
|
||||
|
||||
module.exports.mkdirAsync = mkdirAsync
|
||||
|
||||
module.exports.ensureDatafileIntegrityAsync = ensureDatafileIntegrityAsync
|
||||
|
||||
module.exports.ensureParentDirectoryExistsAsync = ensureParentDirectoryExistsAsync
|
||||
295
node_modules/@seald-io/nedb/browser-version/lib/storage.react-native.js
generated
vendored
Executable file
295
node_modules/@seald-io/nedb/browser-version/lib/storage.react-native.js
generated
vendored
Executable file
@@ -0,0 +1,295 @@
|
||||
/**
|
||||
* Way data is stored for this database
|
||||
*
|
||||
* This version is the React-Native version and uses [@react-native-async-storage/async-storage]{@link https://github.com/react-native-async-storage/async-storage}.
|
||||
* @module storageReactNative
|
||||
* @see module:storageBrowser
|
||||
* @see module:storage
|
||||
* @private
|
||||
*/
|
||||
|
||||
const AsyncStorage = require('@react-native-async-storage/async-storage').default
|
||||
const { callbackify } = require('util')
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.exists}.
|
||||
* @param {string} file
|
||||
* @return {Promise<boolean>}
|
||||
* @async
|
||||
* @alias module:storageReactNative.existsAsync
|
||||
* @see module:storageReactNative.exists
|
||||
*/
|
||||
const existsAsync = async file => {
|
||||
try {
|
||||
const value = await AsyncStorage.getItem(file)
|
||||
if (value !== null) return true // Even if value is undefined, AsyncStorage returns null
|
||||
return false
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @callback module:storageReactNative~existsCallback
|
||||
* @param {boolean} exists
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback returns true if file exists
|
||||
* @function
|
||||
* @param {string} file
|
||||
* @param {module:storageReactNative~existsCallback} cb
|
||||
* @alias module:storageReactNative.exists
|
||||
*/
|
||||
const exists = callbackify(existsAsync)
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.rename}.
|
||||
* @param {string} oldPath
|
||||
* @param {string} newPath
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageReactNative.renameAsync
|
||||
* @async
|
||||
* @see module:storageReactNative.rename
|
||||
*/
|
||||
const renameAsync = async (oldPath, newPath) => {
|
||||
try {
|
||||
const value = await AsyncStorage.getItem(oldPath)
|
||||
if (value === null) await AsyncStorage.removeItem(newPath)
|
||||
else {
|
||||
await AsyncStorage.setItem(newPath, value)
|
||||
await AsyncStorage.removeItem(oldPath)
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('An error happened while renaming, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the item from one path to another
|
||||
* @function
|
||||
* @param {string} oldPath
|
||||
* @param {string} newPath
|
||||
* @param {NoParamCallback} c
|
||||
* @return {void}
|
||||
* @alias module:storageReactNative.rename
|
||||
*/
|
||||
const rename = callbackify(renameAsync)
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.writeFile}.
|
||||
* @param {string} file
|
||||
* @param {string} data
|
||||
* @param {object} [options]
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageReactNative.writeFileAsync
|
||||
* @async
|
||||
* @see module:storageReactNative.writeFile
|
||||
*/
|
||||
const writeFileAsync = async (file, data, options) => {
|
||||
// Options do not matter in react-native setup
|
||||
try {
|
||||
await AsyncStorage.setItem(file, data)
|
||||
} catch (error) {
|
||||
console.warn('An error happened while writing, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the item at given path
|
||||
* @function
|
||||
* @param {string} path
|
||||
* @param {string} data
|
||||
* @param {object} options
|
||||
* @param {function} callback
|
||||
* @alias module:storageReactNative.writeFile
|
||||
*/
|
||||
const writeFile = callbackify(writeFileAsync)
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.appendFile}.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {string} toAppend
|
||||
* @param {object} [options]
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageReactNative.appendFileAsync
|
||||
* @async
|
||||
* @see module:storageReactNative.appendFile
|
||||
*/
|
||||
const appendFileAsync = async (filename, toAppend, options) => {
|
||||
// Options do not matter in react-native setup
|
||||
try {
|
||||
const contents = (await AsyncStorage.getItem(filename)) || ''
|
||||
await AsyncStorage.setItem(filename, contents + toAppend)
|
||||
} catch (error) {
|
||||
console.warn('An error happened appending to file writing, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to the item at given path
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {string} toAppend
|
||||
* @param {object} [options]
|
||||
* @param {function} callback
|
||||
* @alias module:storageReactNative.appendFile
|
||||
*/
|
||||
const appendFile = callbackify(appendFileAsync)
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.readFile}.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {object} [options]
|
||||
* @return {Promise<string>}
|
||||
* @alias module:storageReactNative.readFileAsync
|
||||
* @async
|
||||
* @see module:storageReactNative.readFile
|
||||
*/
|
||||
const readFileAsync = async (filename, options) => {
|
||||
try {
|
||||
return (await AsyncStorage.getItem(filename)) || ''
|
||||
} catch (error) {
|
||||
console.warn('An error happened while reading, skip')
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data at given path
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {object} options
|
||||
* @param {function} callback
|
||||
* @alias module:storageReactNative.readFile
|
||||
*/
|
||||
const readFile = callbackify(readFileAsync)
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.unlink}.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @return {Promise<void>}
|
||||
* @async
|
||||
* @alias module:storageReactNative.unlinkAsync
|
||||
* @see module:storageReactNative.unlink
|
||||
*/
|
||||
const unlinkAsync = async filename => {
|
||||
try {
|
||||
await AsyncStorage.removeItem(filename)
|
||||
} catch (error) {
|
||||
console.warn('An error happened while unlinking, skip')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the data at given path
|
||||
* @function
|
||||
* @param {string} path
|
||||
* @param {function} callback
|
||||
* @alias module:storageReactNative.unlink
|
||||
*/
|
||||
const unlink = callbackify(unlinkAsync)
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.mkdirAsync}, nothing to do, no directories will be used on the react-native.
|
||||
* @function
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @return {Promise<void|string>}
|
||||
* @alias module:storageReactNative.mkdirAsync
|
||||
* @async
|
||||
*/
|
||||
const mkdirAsync = (dir, options) => Promise.resolve()
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.mkdir}, nothing to do, no directories will be used on the react-native.
|
||||
* @function
|
||||
* @param {string} path
|
||||
* @param {object} options
|
||||
* @param {function} callback
|
||||
* @alias module:storageReactNative.mkdir
|
||||
*/
|
||||
const mkdir = callbackify(mkdirAsync)
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.ensureDatafileIntegrityAsync}, nothing to do, no data corruption possible in the react-native.
|
||||
* @param {string} filename
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageReactNative.ensureDatafileIntegrityAsync
|
||||
*/
|
||||
const ensureDatafileIntegrityAsync = (filename) => Promise.resolve()
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.ensureDatafileIntegrity}, nothing to do, no data corruption possible in the react-native.
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {NoParamCallback} callback signature: err
|
||||
* @alias module:storageReactNative.ensureDatafileIntegrity
|
||||
*/
|
||||
const ensureDatafileIntegrity = callbackify(ensureDatafileIntegrityAsync)
|
||||
|
||||
/**
|
||||
* Async version of {@link module:storageReactNative.crashSafeWriteFileLines}.
|
||||
* @param {string} filename
|
||||
* @param {string[]} lines
|
||||
* @return {Promise<void>}
|
||||
* @alias module:storageReactNative.crashSafeWriteFileLinesAsync
|
||||
* @see module:storageReactNative.crashSafeWriteFileLines
|
||||
*/
|
||||
const crashSafeWriteFileLinesAsync = async (filename, lines) => {
|
||||
lines.push('') // Add final new line
|
||||
await writeFileAsync(filename, lines.join('\n'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Fully write or rewrite the datafile, immune to crashes during the write operation (data will not be lost)
|
||||
* @function
|
||||
* @param {string} filename
|
||||
* @param {string[]} lines
|
||||
* @param {NoParamCallback} [callback] Optional callback, signature: err
|
||||
* @alias module:storageReactNative.crashSafeWriteFileLines
|
||||
*/
|
||||
const crashSafeWriteFileLines = callbackify(crashSafeWriteFileLinesAsync)
|
||||
|
||||
/**
|
||||
* Shim for {@link module:storage.ensureParentDirectoryExistsAsync}, nothing to do, no directories will be used on the browser.
|
||||
* @function
|
||||
* @param {string} file
|
||||
* @param {number} [mode]
|
||||
* @return {Promise<void|string>}
|
||||
* @alias module:storageBrowser.ensureParentDirectoryExistsAsync
|
||||
* @async
|
||||
*/
|
||||
const ensureParentDirectoryExistsAsync = async (file, mode) => Promise.resolve()
|
||||
|
||||
// Interface
|
||||
module.exports.exists = exists
|
||||
module.exports.existsAsync = existsAsync
|
||||
|
||||
module.exports.rename = rename
|
||||
module.exports.renameAsync = renameAsync
|
||||
|
||||
module.exports.writeFile = writeFile
|
||||
module.exports.writeFileAsync = writeFileAsync
|
||||
|
||||
module.exports.crashSafeWriteFileLines = crashSafeWriteFileLines
|
||||
module.exports.crashSafeWriteFileLinesAsync = crashSafeWriteFileLinesAsync
|
||||
|
||||
module.exports.appendFile = appendFile
|
||||
module.exports.appendFileAsync = appendFileAsync
|
||||
|
||||
module.exports.readFile = readFile
|
||||
module.exports.readFileAsync = readFileAsync
|
||||
|
||||
module.exports.unlink = unlink
|
||||
module.exports.unlinkAsync = unlinkAsync
|
||||
|
||||
module.exports.mkdir = mkdir
|
||||
module.exports.mkdirAsync = mkdirAsync
|
||||
|
||||
module.exports.ensureDatafileIntegrity = ensureDatafileIntegrity
|
||||
module.exports.ensureDatafileIntegrityAsync = ensureDatafileIntegrityAsync
|
||||
|
||||
module.exports.ensureParentDirectoryExistsAsync = ensureParentDirectoryExistsAsync
|
||||
10155
node_modules/@seald-io/nedb/browser-version/out/nedb.js
generated
vendored
Normal file
10155
node_modules/@seald-io/nedb/browser-version/out/nedb.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/@seald-io/nedb/browser-version/out/nedb.min.js
generated
vendored
Normal file
2
node_modules/@seald-io/nedb/browser-version/out/nedb.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2472
node_modules/@seald-io/nedb/browser-version/out/testutils.js
generated
vendored
Normal file
2472
node_modules/@seald-io/nedb/browser-version/out/testutils.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@seald-io/nedb/browser-version/out/testutils.min.js
generated
vendored
Normal file
1
node_modules/@seald-io/nedb/browser-version/out/testutils.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user