Clean up the oopsie. Rebuild the blank exercises.

This commit is contained in:
Michael Frank
2021-05-09 00:39:21 +12:00
parent b984cb4c6f
commit d28d80c46f
1565 changed files with 27186 additions and 199003 deletions
-3
View File
@@ -1,3 +0,0 @@
{
"presets": ["es2015"]
}
+28 -76
View File
@@ -29,24 +29,12 @@
'use strict';
var Syntax,
isArray,
VisitorOption,
VisitorKeys,
objectCreate,
objectKeys,
BREAK,
SKIP,
REMOVE;
function ignoreJSHintError() { }
isArray = Array.isArray;
if (!isArray) {
isArray = function isArray(array) {
return Object.prototype.toString.call(array) === '[object Array]';
};
}
function deepCopy(obj) {
var ret = {}, key, val;
for (key in obj) {
@@ -62,17 +50,6 @@
return ret;
}
function shallowCopy(obj) {
var ret = {}, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
ret[key] = obj[key];
}
}
return ret;
}
ignoreJSHintError(shallowCopy);
// based on LLVM libc++ upper_bound / lower_bound
// MIT License
@@ -95,52 +72,6 @@
return i;
}
function lowerBound(array, func) {
var diff, len, i, current;
len = array.length;
i = 0;
while (len) {
diff = len >>> 1;
current = i + diff;
if (func(array[current])) {
i = current + 1;
len -= diff + 1;
} else {
len = diff;
}
}
return i;
}
ignoreJSHintError(lowerBound);
objectCreate = Object.create || (function () {
function F() { }
return function (o) {
F.prototype = o;
return new F();
};
})();
objectKeys = Object.keys || function (o) {
var keys = [], key;
for (key in o) {
keys.push(key);
}
return keys;
};
function extend(to, from) {
var keys = objectKeys(from), key, i, len;
for (i = 0, len = keys.length; i < len; i += 1) {
key = keys[i];
to[key] = from[key];
}
return to;
}
Syntax = {
AssignmentExpression: 'AssignmentExpression',
AssignmentPattern: 'AssignmentPattern',
@@ -153,6 +84,7 @@
BreakStatement: 'BreakStatement',
CallExpression: 'CallExpression',
CatchClause: 'CatchClause',
ChainExpression: 'ChainExpression',
ClassBody: 'ClassBody',
ClassDeclaration: 'ClassDeclaration',
ClassExpression: 'ClassExpression',
@@ -177,6 +109,7 @@
GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
Identifier: 'Identifier',
IfStatement: 'IfStatement',
ImportExpression: 'ImportExpression',
ImportDeclaration: 'ImportDeclaration',
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
@@ -227,6 +160,7 @@
BreakStatement: ['label'],
CallExpression: ['callee', 'arguments'],
CatchClause: ['param', 'body'],
ChainExpression: ['expression'],
ClassBody: ['body'],
ClassDeclaration: ['id', 'superClass', 'body'],
ClassExpression: ['id', 'superClass', 'body'],
@@ -251,6 +185,7 @@
GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
Identifier: [],
IfStatement: ['test', 'consequent', 'alternate'],
ImportExpression: ['source'],
ImportDeclaration: ['specifiers', 'source'],
ImportDefaultSpecifier: ['local'],
ImportNamespaceSpecifier: ['local'],
@@ -310,7 +245,7 @@
};
Reference.prototype.remove = function remove() {
if (isArray(this.parent)) {
if (Array.isArray(this.parent)) {
this.parent.splice(this.key, 1);
return true;
} else {
@@ -334,7 +269,7 @@
var i, iz, j, jz, result, element;
function addToPath(result, path) {
if (isArray(path)) {
if (Array.isArray(path)) {
for (j = 0, jz = path.length; j < jz; ++j) {
result.push(path[j]);
}
@@ -434,14 +369,14 @@
this.__state = null;
this.__fallback = null;
if (visitor.fallback === 'iteration') {
this.__fallback = objectKeys;
this.__fallback = Object.keys;
} else if (typeof visitor.fallback === 'function') {
this.__fallback = visitor.fallback;
}
this.__keys = VisitorKeys;
if (visitor.keys) {
this.__keys = extend(objectCreate(this.__keys), visitor.keys);
this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
}
};
@@ -455,6 +390,15 @@
function isProperty(nodeType, key) {
return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
}
function candidateExistsInLeaveList(leavelist, candidate) {
for (var i = leavelist.length - 1; i >= 0; --i) {
if (leavelist[i].node === candidate) {
return true;
}
}
return false;
}
Controller.prototype.traverse = function traverse(root, visitor) {
var worklist,
@@ -530,12 +474,17 @@
continue;
}
if (isArray(candidate)) {
if (Array.isArray(candidate)) {
current2 = candidate.length;
while ((current2 -= 1) >= 0) {
if (!candidate[current2]) {
continue;
}
if (candidateExistsInLeaveList(leavelist, candidate[current2])) {
continue;
}
if (isProperty(nodeType, candidates[current])) {
element = new Element(candidate[current2], [key, current2], 'Property', null);
} else if (isNode(candidate[current2])) {
@@ -546,6 +495,10 @@
worklist.push(element);
}
} else if (isNode(candidate)) {
if (candidateExistsInLeaveList(leavelist, candidate)) {
continue;
}
worklist.push(new Element(candidate, key, null, null));
}
}
@@ -684,7 +637,7 @@
continue;
}
if (isArray(candidate)) {
if (Array.isArray(candidate)) {
current2 = candidate.length;
while ((current2 -= 1) >= 0) {
if (!candidate[current2]) {
@@ -834,7 +787,6 @@
return tree;
}
exports.version = require('./package.json').version;
exports.Syntax = Syntax;
exports.traverse = traverse;
exports.replace = replace;
+15 -18
View File
@@ -1,30 +1,27 @@
{
"_from": "estraverse@^4.2.0",
"_id": "estraverse@4.2.0",
"_from": "estraverse@^5.2.0",
"_id": "estraverse@5.2.0",
"_inBundle": false,
"_integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=",
"_integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
"_location": "/estraverse",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "estraverse@^4.2.0",
"raw": "estraverse@^5.2.0",
"name": "estraverse",
"escapedName": "estraverse",
"rawSpec": "^4.2.0",
"rawSpec": "^5.2.0",
"saveSpec": null,
"fetchSpec": "^4.2.0"
"fetchSpec": "^5.2.0"
},
"_requiredBy": [
"/eslint",
"/eslint-scope",
"/esquery",
"/esrecurse"
"/escodegen"
],
"_resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
"_shasum": "0dee3fed31fcd469618ce7342099fc1afa0bdb13",
"_spec": "estraverse@^4.2.0",
"_where": "/Users/cloyd/coderrr/odin/javascript-exercises/node_modules/eslint",
"_resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
"_shasum": "307df42547e6cc7324d3cf03c155d5cdb8c53880",
"_spec": "estraverse@^5.2.0",
"_where": "/home/michael/projects/javascript-exercises/node_modules/escodegen",
"bugs": {
"url": "https://github.com/estools/estraverse/issues"
},
@@ -32,7 +29,7 @@
"deprecated": false,
"description": "ECMAScript JS AST traversal functions",
"devDependencies": {
"babel-preset-es2015": "^6.3.13",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.3.13",
"chai": "^2.1.1",
"espree": "^1.11.0",
@@ -40,12 +37,12 @@
"gulp-bump": "^0.2.2",
"gulp-filter": "^2.0.0",
"gulp-git": "^1.0.1",
"gulp-tag-version": "^1.2.1",
"gulp-tag-version": "^1.3.0",
"jshint": "^2.5.6",
"mocha": "^2.1.0"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4.0"
},
"homepage": "https://github.com/estools/estraverse",
"license": "BSD-2-Clause",
@@ -67,5 +64,5 @@
"test": "npm run-script lint && npm run-script unit-test",
"unit-test": "mocha --compilers js:babel-register"
},
"version": "4.2.0"
"version": "5.2.0"
}