Skip to content

Commit

Permalink
🤖 chore: Lint source files.
Browse files Browse the repository at this point in the history
These changes were automatically generated by a transform whose code can be found at:
  - https://github.com/aureooms/rejuvenate/blob/a5a57b70ac6fd6fb77fdab32e6b7be7519ce9564/src/transforms/sources:initial-lint.js
Please contact the author of the transform if you believe there was an error.
  • Loading branch information
a-flying-potato authored and make-github-pseudonymous-again committed Mar 17, 2021
1 parent 5de4ffc commit 7ffc7f1
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 86 deletions.
40 changes: 18 additions & 22 deletions doc/scripts/header.js
@@ -1,34 +1,30 @@
var domReady = function(callback) {
var state = document.readyState ;
if ( state === 'interactive' || state === 'complete' ) {
callback() ;
}
else {
const domReady = function (callback) {
const state = document.readyState;
if (state === 'interactive' || state === 'complete') {
callback();
} else {
document.addEventListener('DOMContentLoaded', callback);
}
} ;

};

domReady(function(){

var projectname = document.createElement('a');
domReady(() => {
const projectname = document.createElement('a');
projectname.classList.add('project-name');
projectname.text = 'aureooms/js-error';
projectname.href = './index.html' ;
projectname.href = './index.html';

var header = document.getElementsByTagName('header')[0] ;
header.insertBefore(projectname,header.firstChild);
const header = document.querySelectorAll('header')[0];
header.insertBefore(projectname, header.firstChild);

var testlink = document.querySelector('header > a[data-ice="testLink"]') ;
testlink.href = 'https://coveralls.io/github/aureooms/js-error' ;
testlink.target = '_BLANK' ;
const testlink = document.querySelector('header > a[data-ice="testLink"]');
testlink.href = 'https://coveralls.io/github/aureooms/js-error';
testlink.target = '_BLANK';

var searchBox = document.querySelector('.search-box');
var input = document.querySelector('.search-input');
const searchBox = document.querySelector('.search-box');
const input = document.querySelector('.search-input');

// active search box when focus on searchBox.
input.addEventListener('focus', function(){
// Active search box when focus on searchBox.
input.addEventListener('focus', () => {
searchBox.classList.add('active');
});

});
2 changes: 1 addition & 1 deletion src/Error.js
@@ -1 +1 @@
export default Error ;
export default Error;
4 changes: 2 additions & 2 deletions src/IndexError.js
@@ -1,3 +1,3 @@
import customError from "./customError.js" ;
import customError from './customError.js';

export default customError('IndexError') ;
export default customError('IndexError');
4 changes: 2 additions & 2 deletions src/KeyError.js
@@ -1,3 +1,3 @@
import customError from "./customError.js" ;
import customError from './customError.js';

export default customError('KeyError') ;
export default customError('KeyError');
4 changes: 2 additions & 2 deletions src/NotImplementedError.js
@@ -1,3 +1,3 @@
import customError from "./customError.js" ;
import customError from './customError.js';

export default customError('NotImplementedError') ;
export default customError('NotImplementedError');
4 changes: 2 additions & 2 deletions src/StopIteration.js
@@ -1,3 +1,3 @@
import customError from "./customError.js" ;
import customError from './customError.js';

export default customError('StopIteration') ;
export default customError('StopIteration');
2 changes: 1 addition & 1 deletion src/SyntaxError.js
@@ -1 +1 @@
export default SyntaxError ;
export default SyntaxError;
2 changes: 1 addition & 1 deletion src/TypeError.js
@@ -1 +1 @@
export default TypeError ;
export default TypeError;
4 changes: 2 additions & 2 deletions src/ValueError.js
@@ -1,3 +1,3 @@
import customError from "./customError.js" ;
import customError from './customError.js';

export default customError('ValueError') ;
export default customError('ValueError');
6 changes: 3 additions & 3 deletions src/customError.js
@@ -1,5 +1,5 @@
import Error from "./Error.js" ;
import extendError from "./extendError.js" ;
import Error from './Error.js';
import extendError from './extendError.js';

const customError = name => extendError( Error , name ) ;
const customError = (name) => extendError(Error, name);
export default customError;
45 changes: 22 additions & 23 deletions src/extendError.js
@@ -1,33 +1,32 @@
export default function extendError ( parent, name ) {
export default function extendError(parent, name) {
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
const CustomError = function (...parameters) {
const instance = new Error(...parameters);
instance.name = name;
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
if (Error.captureStackTrace) {
Error.captureStackTrace(instance, CustomError);
}

const CustomError = function (...params) {
const instance = new Error(...params);
instance.name = name;
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
if (Error.captureStackTrace) {
Error.captureStackTrace(instance, CustomError);
}
return instance;
}
return instance;
};

CustomError.prototype = Object.create(Error.prototype, {
constructor: {
value: Error,
enumerable: false,
writable: true,
configurable: true
}
constructor: {
value: Error,
enumerable: false,
writable: true,
configurable: true,
},
});

if (Object.setPrototypeOf){
Object.setPrototypeOf(CustomError, Error);
if (Object.setPrototypeOf) {
Object.setPrototypeOf(CustomError, Error);
} else {
// eslint-disable-next-line no-proto
CustomError.__proto__ = Error;
// eslint-disable-next-line no-proto
CustomError.__proto__ = Error;
}

return CustomError ;

return CustomError;
}
53 changes: 28 additions & 25 deletions test/src/error.js
@@ -1,39 +1,42 @@
import test from 'ava' ;
import test from 'ava';

import {
Error ,
TypeError ,
SyntaxError ,
IndexError ,
KeyError ,
NotImplementedError ,
ValueError ,
StopIteration ,
} from "../../src/index.js" ;
Error,
TypeError,
SyntaxError,
IndexError,
KeyError,
NotImplementedError,
ValueError,
StopIteration,
} from '../../src/index.js';

const errors = [
Error ,
TypeError ,
SyntaxError ,
IndexError ,
KeyError ,
NotImplementedError ,
ValueError ,
StopIteration ,
] ;
Error,
TypeError,
SyntaxError,
IndexError,
KeyError,
NotImplementedError,
ValueError,
StopIteration,
];

const macro = (t, SpecificError) => {

const r = Math.random();
const s = r.toString();

t.truthy( new SpecificError( ) ) ;
t.is( ( new SpecificError( r ) ).message , s ) ;
t.throws( () => { throw new SpecificError() ; } , { instanceOf: SpecificError } ) ;

t.truthy(new SpecificError());
t.is(new SpecificError(r).message, s);
t.throws(
() => {
throw new SpecificError();
},
{instanceOf: SpecificError},
);
};

macro.title = (title, SpecificError) => title || (new SpecificError()).name;
macro.title = (title, SpecificError) => title || new SpecificError().name;

for (const error of errors) {
test(macro, error);
Expand Down

0 comments on commit 7ffc7f1

Please sign in to comment.