Commit 9189891c authored by Aurel's avatar Aurel

tell jslint this is node scripts

parent 560504ee
......@@ -75,15 +75,17 @@ module.exports = function (grunt) {
maxlen: 80,
indent: 2,
maxerr: 3,
node: true,
nomen: true
}
},
jio_nodejs_include: {
src: ['src/nodejs/include.js'],
src: ['src/nodejs/*.js'],
directives: {
maxlen: 80,
indent: 2,
maxerr: 3,
node: true,
nomen: true
}
},
......
(function (env) {
"use strict";
const process = require("process");
var process = require("process");
env._html5_weakmap = new WeakMap();
function EventTarget() { env._html5_weakmap.set(this, Object.create(null)); }
EventTarget.prototype.addEventListener = function (type, listener) {
if (typeof listener !== "function") return;
const em = env._html5_weakmap.get(this);
var em = env._html5_weakmap.get(this);
type = "" + type;
if (em[type]) em[type].push(listener);
else em[type] = [listener];
};
EventTarget.prototype.removeEventListener = function (type, listener) {
if (typeof listener !== "function") return;
const em = env._html5_weakmap.get(this);
var em = env._html5_weakmap.get(this);
var i = 0, listeners = em[type];
type = "" + type;
if (listeners) for (; i < listeners.length; ++i) if (listeners[i] === listener) {
......@@ -24,7 +24,7 @@
}
};
EventTarget.prototype.dispatchEvent = function (event) {
const type = "" + event.type,
var type = "" + event.type,
em = env._html5_weakmap.get(this),
ontype = "on" + type;
var i = 0, listeners;
......@@ -39,7 +39,7 @@
function Blob(blobParts, options) {
// https://developer.mozilla.org/en-US/docs/Web/API/Blob
var i = 0; const priv = {}, buffers = [];
var i = 0; var priv = {}, buffers = [];
env._html5_weakmap.set(this, priv);
for (; i < blobParts.length; ++i) {
if (Buffer.isBuffer(blobParts[i])) {
......@@ -67,27 +67,27 @@
FileReader.prototype = Object.create(EventTarget.prototype);
Object.defineProperty(FileReader, "constructor", {value: FileReader});
FileReader.prototype.readAsText = function (blob) {
const priv = env._html5_weakmap.get(blob);
const text = priv.data.toString();
const event = Object.freeze({type: "load", target: this});
var priv = env._html5_weakmap.get(blob);
var text = priv.data.toString();
var event = Object.freeze({type: "load", target: this});
process.nextTick(() => {
this.result = text;
this.dispatchEvent(event);
});
};
FileReader.prototype.readAsArrayBuffer = function (blob) {
const priv = env._html5_weakmap.get(blob);
const arrayBuffer = new Uint8Array(priv.data).buffer;
const event = Object.freeze({type: "load", target: this});
var priv = env._html5_weakmap.get(blob);
var arrayBuffer = new Uint8Array(priv.data).buffer;
var event = Object.freeze({type: "load", target: this});
process.nextTick(() => {
this.result = arrayBuffer;
this.dispatchEvent(event);
});
};
FileReader.prototype.readAsDataURL = function (blob) {
const priv = env._html5_weakmap.get(blob);
const dataUrl = "data:" + blob.type + ";base64," + priv.data.toString("base64");
const event = Object.freeze({type: "load", target: this});
var priv = env._html5_weakmap.get(blob);
var dataUrl = "data:" + blob.type + ";base64," + priv.data.toString("base64");
var event = Object.freeze({type: "load", target: this});
process.nextTick(() => {
this.result = dataUrl;
this.dispatchEvent(event);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment