Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

cleanups/improvements #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/package-lock.json
5 changes: 4 additions & 1 deletion buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@
END_NODE_INCLUDE
*/




/**
* @type {Object.<string,*>}
*/
var buffer = {};

/**
* @param {...*} var_args
* @constructor
* @param {...*} var_args
* @nosideeffects
*/
buffer.Buffer = function(var_args) {};
Expand Down
63 changes: 63 additions & 0 deletions contrib/mime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2012 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @fileoverview Definitions for the mime module.
* @see https://www.npmjs.com/package/mime
* @see https://github.com/broofa/node-mime
* @externs
* @author Jay Shepherd <zysennz@gmail.com>
*/

/**
BEGIN_NODE_INCLUDE
var mime = require('mime');
END_NODE_INCLUDE
*/


var mime = {R_OK: {}};

/**
* Define mimetype -> xtension mappings. Each key is a mime-type that maps
* to an array of extensions associated with the type. The first extension is
* used as the default extension for the type.
*
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
*
* If a type declares an extension that has already been defined, an error will
* be thrown. To suppress this error and force the extension to be associated
* with the new type, pass `force`=true. Alternatively, you may prefix the
* extension with "*" to map the type to extension, without mapping the
* extension to the type.
*
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
*
*
* @param typeMap (Object) type definitions
* @param force (Boolean) if true, force overriding of existing definitions
*/
mime.define = function(typeMap, force) {};

/**
* Lookup a mime type based on extension
*/
mime.getType = function(path) {};

/**
* Return file extension associated with a mime type
*/
mime.getExtension = function(type) {};
4 changes: 0 additions & 4 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,3 @@ module.children;
*/
var global = {};

/**
* @type {buffer.Buffer}
*/
var Buffer;
10 changes: 10 additions & 0 deletions fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@

var fs = {};



/** @enum {number} */
fs.constants = {};

/**
* @type {number}
*/
fs.constants.R_OK;

/**
* @param {string} oldPath
* @param {string} newPath
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"author": "Daniel Wirtz <dcode@dcode.io>",
"description": "A collection of node.js externs for use with ClosureCompiler.js.",
"contributors": [
{ "name": "Daniel Wirtz", "email": "dcode@dcode.io" }
{
"name": "Daniel Wirtz",
"email": "dcode@dcode.io"
}
],
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion redundant/stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

/**
* @type {Object.<string,function(*, ...[*])>}
* @type {Object.<string,function(*, ...)>}
*/
var console = {};

Expand Down
4 changes: 2 additions & 2 deletions redundant/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

/**
* @param {function(...[*])} callback
* @param {function(...)} callback
* @param {number} delay
* @param {...*} var_args
* @return {*}
Expand All @@ -36,7 +36,7 @@ function setTimeout(callback, delay, var_args) {};
function clearTimeout(timeoutId) {};

/**
* @param {function(...[*])} callback
* @param {function(...)} callback
* @param {number} delay
* @param {...*} var_args
* @return {*}
Expand Down
13 changes: 8 additions & 5 deletions tests/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ for (var i=0; i<files.length; i++) {
externs.push("./"+files[i]);
}
}
/* files = fs.readdirSync("./contrib");
/*
files = fs.readdirSync("./contrib");
for (i=0; i<files.length; i++) {
if (pattern.test(files[i])) {
externs.push("./contrib/"+files[i]);
}
} */
}
*/

console.log("Validating "+externs.length+" files:\n", externs);
ClosureCompiler.compile("./tests/noop.js", {
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"warning_level": "verbose",
"externs": externs
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"warning_level": "verbose",
"env": "CUSTOM",
"externs": externs
}, function(error, result) {
if (error) {
throw(error);
Expand Down