clean up types, add missing jsdoc parameters, add some descriptions

This commit is contained in:
Sebastian McKenzie 2015-01-30 21:48:32 +11:00
parent 1cbbe00b7a
commit f5ccb9c0ba

View File

@ -13,10 +13,6 @@ var isString = require("lodash/lang/isString");
var t = exports; var t = exports;
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
//
/** /**
* Registers `is[Type]` and `assert[Type]` generated functions for a given `type`. * Registers `is[Type]` and `assert[Type]` generated functions for a given `type`.
* Pass `skipAliasCheck` to force it to directly compare `node.type` with `type`. * Pass `skipAliasCheck` to force it to directly compare `node.type` with `type`.
@ -39,8 +35,7 @@ function registerType(type, skipAliasCheck) {
} }
t.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body"]; t.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body"];
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
//
t.VISITOR_KEYS = require("./visitor-keys"); t.VISITOR_KEYS = require("./visitor-keys");
@ -66,6 +61,7 @@ each(t.FLIPPED_ALIAS_KEYS, function (types, type) {
/** /**
* Returns whether `node` is of given `type`. * Returns whether `node` is of given `type`.
*
* For better performance, use this instead of `is[Type]` when `type` is unknown. * For better performance, use this instead of `is[Type]` when `type` is unknown.
* Optionally, pass `skipAliasCheck` to directly compare `node.type` with `type`. * Optionally, pass `skipAliasCheck` to directly compare `node.type` with `type`.
* *
@ -156,6 +152,9 @@ t.isFalsyExpression = function (node) {
* declarations hoisted to the top of the current scope. * declarations hoisted to the top of the current scope.
* *
* Expression statements are just resolved to their standard expression. * Expression statements are just resolved to their standard expression.
*
* @param {Array} nodes
* @param {Scope} scope
*/ */
t.toSequenceExpression = function (nodes, scope) { t.toSequenceExpression = function (nodes, scope) {
@ -185,17 +184,23 @@ t.toSequenceExpression = function (nodes, scope) {
} }
}; };
// /*
* Description
*
* @param {Object} actual
* @param {Object} expected
* @returns {Boolean}
*/
t.shallowEqual = function (actual, expected) { t.shallowEqual = function (actual, expected) {
var keys = Object.keys(expected); var keys = Object.keys(expected);
var key;
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
key = keys[i]; var key = keys[i];
if (actual[key] !== expected[key]) if (actual[key] !== expected[key]) {
return false; return false;
}
} }
return true; return true;
@ -330,7 +335,7 @@ t.isReferenced = function (node, parent) {
}; };
/** /**
* Description * Check if the input `node` is an `Identifier` and `isReferenced`.
* *
* @param {Object} node * @param {Object} node
* @param {Object} parent * @param {Object} parent
@ -342,7 +347,8 @@ t.isReferencedIdentifier = function (node, parent) {
}; };
/** /**
* Description * Check if the input `name` is a valid identifier name
* and isn't a reserved word.
* *
* @param {String} name * @param {String} name
* @returns {Boolean} * @returns {Boolean}