Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup: replace function declarations with function expressions

  • Loading branch information...
commit 72c91701217384d065818066d5e84d1b75651bfa 1 parent ca9f126
@davidchambers davidchambers authored
Showing with 12 additions and 12 deletions.
  1. +8 −8 lib/api/attributes.js
  2. +2 −2 lib/cheerio.js
  3. +2 −2 lib/static.js
View
16 lib/api/attributes.js
@@ -9,7 +9,7 @@ var _ = require('underscore'),
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i;
-function setAttr(el, name, value) {
+var setAttr = function(el, name, value) {
if (typeof name === 'object') return _.extend(el.attribs, name);
if (value === null) {
@@ -19,7 +19,7 @@ function setAttr(el, name, value) {
}
return el.attribs;
-}
+};
var attr = exports.attr = function(name, value) {
var elem = this[0];
@@ -55,7 +55,7 @@ var attr = exports.attr = function(name, value) {
* Remove an attribute
*/
-function removeAttribute(elem, name) {
+var removeAttribute = function(elem, name) {
if (!isTag(elem.type) || !elem.attribs || !Object.hasOwnProperty.call(elem.attribs, name))
return;
@@ -63,7 +63,7 @@ function removeAttribute(elem, name) {
elem.attribs[name] = false;
else
delete elem.attribs[name];
-}
+};
var removeAttr = exports.removeAttr = function(name) {
@@ -126,11 +126,11 @@ var addClass = exports.addClass = function(value) {
};
var removeClass = exports.removeClass = function(value) {
- var classes = split(value);
+ var split = function(className) {
+ return className ? className.trim().split(rspace) : [];
+ };
- function split(className) {
- return !className ? [] : className.trim().split(rspace);
- }
+ var classes = split(value);
// Handle if value is a function
if (_.isFunction(value)) {
View
4 lib/cheerio.js
@@ -109,14 +109,14 @@ Cheerio.prototype.sort = [].splice;
/*
* Check if string is HTML
*/
-function isHtml(str) {
+var isHtml = function(str) {
// Faster than running regex, if str starts with `<` and ends with `>`, assume it's HTML
if (str.charAt(0) === '<' && str.charAt(str.length - 1) === '>' && str.length >= 3) return true;
// Run the regex
var match = quickExpr.exec(str);
return !!(match && match[1]);
-}
+};
/*
* Make a cheerio object
View
4 lib/static.js
@@ -15,9 +15,9 @@ var load = exports.load = function(str, options) {
var Cheerio = require('./cheerio'),
root = parse(str, options);
- function initialize(selector, context, r) {
+ var initialize = function(selector, context, r) {
return new Cheerio(selector, context, r || root);
- }
+ };
// Add in the static methods
initialize.__proto__ = exports;
Please sign in to comment.
Something went wrong with that request. Please try again.