First release

This commit is contained in:
Owen Quinlan 2021-07-02 19:29:34 +10:00
commit fa6c85266e
2339 changed files with 761050 additions and 0 deletions

11
node_modules/rust-result/.editorconfig generated vendored Normal file
View file

@ -0,0 +1,11 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

3
node_modules/rust-result/.jshintrc generated vendored Normal file
View file

@ -0,0 +1,3 @@
{
"indent": 2
}

3
node_modules/rust-result/.npmignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
npm-debug.log
coverage/
node_modules

19
node_modules/rust-result/LICENSE generated vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (C) 2014 by Maciej Małecki
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

120
node_modules/rust-result/README.md generated vendored Normal file
View file

@ -0,0 +1,120 @@
# rust-result.js
Mimic Rust's [`std::result`][result].
## Installation
```sh
npm install rust-result
```
## Usage
```js
var fs = require('fs');
var Result = require('./');
// If you want async just get a promise or something.
var readFile = function (path, encoding) {
try {
return Result.Ok(fs.readFileSync(path, encoding))
}
catch (ex) {
return Result.Err(ex)
}
}
var result = readFile(__filename);
var v, err;
if (Result.isOk(result)) {
v = Result.Ok(result);
console.log('got ' + v.length + ' bytes')
}
else if (Result.isErr(result)) {
err = Result.Err(result);
console.error('oops!', err.message)
}
result = readFile(__filename + 'I do not exist')
if (Result.isOk(result)) {
v = Result.Ok(result)
console.log('got ' + v.length + ' bytes')
}
else if (Result.isErr(result)) {
err = Result.Err(result)
console.error('oops!', err.message)
}
```
## Documentation
```jsig
type OkResult<T> : {
v: T
}
type ErrResult<E <: Error> : {
err: E
}
rust-result : {
Ok: ((T) => OkResult<T>) |
((OkResult<T>) => T) |
((ErrResult<E>) => void),
isOk: ((OkResult<T>) => true) |
((ErrResult<E>) => false)
Err: ((E <: Error) => ErrResult<E>) |
((ErrResult<E>) => E) |
((OkResult<T>) => void),
isErr: ((ErrResult<E>) => true) |
((OkResult<T>) => false)
}
```
### `Result.Ok`
The `Result.Ok` function is overloaded to do one of two things.
It can create a new `Ok` instance or it can check whether
the argument is an instance of `Ok`
If you call `Result.Ok` with a plain value it will return an
instance of `Ok` that boxes your plain value.
If you call `Result.Ok` with either an `Err` or an `Ok` instance
then it will return `undefined` for the `Err` and return the
value boxed in the `Ok`
### `Result.isOk`
The `Result.isOk` function just checks whether the argument
is an instance of `Ok`.
This predicate function returns true if you pass it an `Ok` and
returns false if you pass it an `Err`
### `Result.Err`
The `Result.Err` function is overloaded to do one of two things.
It can create a new `Err` instance or it can check whether
the argument is an instance of `Err`
If you call `Result.Err` with a plain error it will return an
instance of `Err` that boxes your plain error.
If you call `Result.Err` with either an `Err` or an `Ok` instance
then it will return `undefined` for the `Ok` and return the
value err in the `Err`
### `Result.isErr`
The `Result.isErr` function just checks whether the argument
is an instance of `Err`.
This predicate function returns true if you pass it an `Err` and
returns false if you pass it an `Ok`
## MIT Licenced.
[result]: http://doc.rust-lang.org/std/result/

35
node_modules/rust-result/example.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
var fs = require('fs');
var Result = require('./');
// If you want async just get a promise or something.
var readFile = function (path, encoding) {
try {
return Result.Ok(fs.readFileSync(path, encoding))
}
catch (ex) {
return Result.Err(ex)
}
}
var result = readFile(__filename);
var v, err;
if (Result.isOk(result)) {
v = Result.Ok(result);
console.log('got ' + v.length + ' bytes')
}
else if (Result.isErr(result)) {
err = Result.Err(result);
console.error('oops!', err.message)
}
result = readFile(__filename + 'I do not exist')
if (Result.isOk(result)) {
v = Result.Ok(result)
console.log('got ' + v.length + ' bytes')
}
else if (Result.isErr(result)) {
err = Result.Err(result)
console.error('oops!', err.message)
}

81
node_modules/rust-result/index.js generated vendored Normal file
View file

@ -0,0 +1,81 @@
var Individual = require('individual')
var VERSION_KEY = '1';
var ERROR_CACHE_KEY = '__RUST_RESULT_ERROR_UUID@' + VERSION_KEY
var OK_CACHE_KEY = '__RUST_RESULT_OK_UUID@' + VERSION_KEY
var ERROR_UUID = Individual(ERROR_CACHE_KEY, fakeUUID('Error'))
var OK_UUID = Individual(OK_CACHE_KEY, fakeUUID('Ok'))
function Ok(v) {
this.v = v
this[OK_UUID] = true
}
function Err(err) {
this.err = err
this[ERROR_UUID] = true
}
function createOk(v) {
if (isObject(v) && OK_UUID in v) {
return v.v
} else if (isObject(v) && ERROR_UUID in v) {
return undefined
} else {
if (v === undefined) {
throw Error('rust-result: Cannot box `undefined` in Result.Ok')
}
return new Ok(v)
}
}
function createErr(err) {
if (isObject(err) && ERROR_UUID in err) {
return err.err
} else if (isObject(err) && OK_UUID in err) {
return undefined
} else {
if (!isError(err)) {
throw Error('rust-result: Cannot box a non-error in Result.Err')
}
return new Err(err)
}
}
function isOk(v) {
return createOk(v) !== undefined
}
function isErr(err) {
return createErr(err) !== undefined
}
module.exports = {
isOk: isOk,
Ok: createOk,
isErr: isErr,
Err: createErr
}
function fakeUUID(word) {
return 'rust-result:' + word + ':' +
Math.random().toString(32).slice(2) + ':' +
Math.random().toString(32).slice(2) + ':' +
Math.random().toString(32).slice(2) + ':' +
Math.random().toString(32).slice(2) + ':'
}
function isObject(o) {
return typeof o === 'object' && o !== null
}
function isError(e) {
return isObject(e) &&
(Object.prototype.toString.call(e) === '[object Error]' ||
/* istanbul ignore next */ e instanceof Error)
}

57
node_modules/rust-result/package.json generated vendored Normal file
View file

@ -0,0 +1,57 @@
{
"_from": "rust-result@^1.0.0",
"_id": "rust-result@1.0.0",
"_inBundle": false,
"_integrity": "sha1-NMdbLm3Dn+WHXlveyFteD5FTb3I=",
"_location": "/rust-result",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "rust-result@^1.0.0",
"name": "rust-result",
"escapedName": "rust-result",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/safe-json-parse"
],
"_resolved": "https://registry.npmjs.org/rust-result/-/rust-result-1.0.0.tgz",
"_shasum": "34c75b2e6dc39fe5875e5bdec85b5e0f91536f72",
"_spec": "rust-result@^1.0.0",
"_where": "F:\\Documents\\websites\\BMM\\node_modules\\safe-json-parse",
"author": {
"name": "Maciej Małecki",
"email": "me@mmalecki.com"
},
"bugs": {
"url": "https://github.com/mmalecki/rust-result.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"individual": "^2.0.0"
},
"deprecated": false,
"description": "Mimic Rust's `std::result`",
"devDependencies": {
"istanbul": "^0.3.5",
"opn": "^1.0.0",
"tape": "^3.0.1"
},
"homepage": "https://github.com/mmalecki/rust-result.js",
"license": "MIT",
"main": "index",
"name": "rust-result",
"repository": {
"type": "git",
"url": "git://github.com/mmalecki/rust-result.js.git"
},
"scripts": {
"cover": "istanbul cover --print detail --report html test.js",
"test": "node test.js",
"view-cover": "istanbul report html && opn ./coverage/index.html"
},
"version": "1.0.0"
}

88
node_modules/rust-result/test.js generated vendored Normal file
View file

@ -0,0 +1,88 @@
var test = require('tape')
var Result = require('./index.js')
test('can create Ok', function t(assert) {
var v = Result.Ok(42)
assert.equal(!!v, true)
assert.equal(v.v, 42)
assert.end()
})
test('can check for Ok', function t(assert) {
var result = Result.Ok(42)
assert.equal(Result.isOk(result), true)
assert.equal(Result.Ok(result), 42)
assert.end()
})
test('check for Ok fails for Err', function t(assert) {
var result = Result.Err(new Error('foo'))
assert.equal(Result.isOk(result), false)
assert.equal(Result.Ok(result), undefined)
assert.end()
})
test('can create Err', function t(assert) {
var err = Result.Err(new Error('foo'))
assert.equal(!!err, true)
assert.equal(err.err.message, 'foo')
assert.end()
})
test('can check for Err', function t(assert) {
var result = Result.Err(new Error('foo'))
assert.equal(Result.isErr(result), true)
assert.equal(Result.Err(result).message, 'foo')
assert.end()
})
test('check for Err fails for Ok', function t(assert) {
var result = Result.Ok(42)
assert.equal(Result.isErr(result), false)
assert.equal(Result.Err(result), undefined)
assert.end()
})
test('Ok can support null value', function t(assert) {
var result = Result.Ok(null)
assert.equal(!!result, true)
assert.equal(result.v, null)
assert.equal(Result.isOk(result), true)
assert.equal(Result.Ok(result), null)
assert.equal(Result.isErr(result), false)
assert.equal(Result.Err(result), undefined)
assert.end()
})
test('Ok throws if you box undefined', function t(assert) {
assert.throws(function () {
Result.Ok(undefined)
}, /Cannot box `undefined` in Result.Ok/)
assert.end()
})
test('Err throws if you box non-error', function t(assert) {
assert.throws(function () {
Result.Err(42)
}, /Cannot box a non-error in Result.Err/)
assert.end()
})