Revert "Commit updated Javascript packages"

This reverts commit a88734348a.
This commit is contained in:
Gabe Kangas
2020-10-19 22:14:27 -07:00
parent a88734348a
commit 3f50ce9bfc
6368 changed files with 0 additions and 603959 deletions

View File

@@ -1,11 +0,0 @@
# 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

View File

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

View File

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

View File

@@ -1,19 +0,0 @@
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.

View File

@@ -1,120 +0,0 @@
# 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/

View File

@@ -1,35 +0,0 @@
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)
}

View File

@@ -1,81 +0,0 @@
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)
}

View File

@@ -1,60 +0,0 @@
{
"_args": [
[
"rust-result@1.0.0",
"/home/runner/work/owncast/owncast/build/javascript"
]
],
"_from": "rust-result@1.0.0",
"_id": "rust-result@1.0.0",
"_inBundle": false,
"_integrity": "sha1-NMdbLm3Dn+WHXlveyFteD5FTb3I=",
"_location": "/rust-result",
"_phantomChildren": {},
"_requested": {
"type": "version",
"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",
"_spec": "1.0.0",
"_where": "/home/runner/work/owncast/owncast/build/javascript",
"author": {
"name": "Maciej Małecki",
"email": "me@mmalecki.com"
},
"bugs": {
"url": "https://github.com/mmalecki/rust-result.js/issues"
},
"dependencies": {
"individual": "^2.0.0"
},
"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"
}

View File

@@ -1,88 +0,0 @@
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()
})