Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

42
torrent-project/node_modules/webpack/lib/util/Queue.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
module.exports = class Queue {
constructor(items) {
this.first = null;
this.last = null;
this.length = 0;
if(items) {
for(const item of items) {
this.enqueue(item);
}
}
}
enqueue(item) {
const first = this.first;
const node = {
item,
next: null
};
if(first === null) {
this.last = node;
} else {
first.next = node;
}
this.first = node;
this.length++;
}
dequeue() {
const last = this.last;
if(last === null)
return undefined;
const next = last.next;
if(next === null) {
this.first = null;
}
this.last = next;
this.length--;
return last.item;
}
};

View File

@@ -0,0 +1,32 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
class Semaphore {
constructor(available) {
this.available = available;
this.waiters = [];
}
acquire(callback) {
if(this.available > 0) {
this.available--;
callback();
} else {
this.waiters.push(callback);
}
}
release() {
if(this.waiters.length > 0) {
const callback = this.waiters.pop();
process.nextTick(callback);
} else {
this.available++;
}
}
}
module.exports = Semaphore;

View File

@@ -0,0 +1,45 @@
"use strict";
module.exports = class SortableSet extends Set {
constructor(initialIterable, defaultSort) {
super(initialIterable);
this._sortFn = defaultSort;
this._lastActiveSortFn = null;
}
/**
* @param {any} value - value to add to set
* @returns {SortableSet} - returns itself
*/
add(value) {
this._lastActiveSortFn = null;
super.add(value);
return this;
}
/**
* @param {Function} sortFn - function to sort the set
* @returns {void}
*/
sortWith(sortFn) {
if(this.size === 0 || sortFn === this._lastActiveSortFn) {
// already sorted - nothing to do
return;
}
const sortedArray = Array.from(this).sort(sortFn);
super.clear();
for(let i = 0; i < sortedArray.length; i += 1) {
this.add(sortedArray[i]);
}
this._lastActiveSortFn = sortFn;
}
/**
* @returns {void}
*/
sort() {
this.sortWith(this._sortFn);
}
};

View File

@@ -0,0 +1,38 @@
"use strict";
const path = require("path");
const looksLikeAbsolutePath = (maybeAbsolutePath) => {
return /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);
};
const normalizePathSeparator = (p) => p.replace(/\\/g, "/");
const _makePathsRelative = (context, identifier) => {
return identifier
.split(/([|! ])/)
.map(str => looksLikeAbsolutePath(str) ?
normalizePathSeparator(path.relative(context, str)) : str)
.join("");
};
exports.makePathsRelative = (context, identifier, cache) => {
if(!cache) return _makePathsRelative(context, identifier);
const relativePaths = cache.relativePaths || (cache.relativePaths = new Map());
let cachedResult;
let contextCache = relativePaths.get(context);
if(typeof contextCache === "undefined") {
relativePaths.set(context, contextCache = new Map());
} else {
cachedResult = contextCache.get(identifier);
}
if(typeof cachedResult !== "undefined") {
return cachedResult;
} else {
const relativePath = _makePathsRelative(context, identifier);
contextCache.set(identifier, relativePath);
return relativePath;
}
};