diff --git a/bind.js b/bind.js index 413a17e..462ac45 100644 --- a/bind.js +++ b/bind.js @@ -1,10 +1,10 @@ -var hasOwn = {}.hasOwnProperty; +const hasOwn = {}.hasOwnProperty; export default function classNames () { - var classes = ''; + let classes = ''; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; + for (let i = 0; i < arguments.length; i++) { + const arg = arguments[i]; if (arg) { classes = appendClass(classes, parseValue.call(this, arg)); } @@ -30,9 +30,9 @@ function parseValue (arg) { return arg.toString(); } - var classes = ''; + let classes = ''; - for (var key in arg) { + for (const key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes = appendClass(classes, this && this[key] || key); } diff --git a/dedupe.js b/dedupe.js index 61330d2..7de3f16 100644 --- a/dedupe.js +++ b/dedupe.js @@ -5,14 +5,14 @@ var classNames = (function () { StorageObject.prototype = Object.create(null); function _parseArray (resultSet, array) { - var length = array.length; + const length = array.length; for (var i = 0; i < length; ++i) { _parse(resultSet, array[i]); } } - var hasOwn = {}.hasOwnProperty; + const hasOwn = {}.hasOwnProperty; function _parseNumber (resultSet, num) { resultSet[num] = true; @@ -24,7 +24,7 @@ var classNames = (function () { return; } - for (var k in object) { + for (const k in object) { if (hasOwn.call(object, k)) { // set value to false instead of deleting it to avoid changing object structure // https://www.smashingmagazine.com/2012/11/writing-fast-memory-efficient-javascript/#de-referencing-misconceptions @@ -33,19 +33,19 @@ var classNames = (function () { } } - var SPACE = /\s+/; + const SPACE = /\s+/; function _parseString (resultSet, str) { - var array = str.split(SPACE); - var length = array.length; + const array = str.split(SPACE); + const length = array.length; - for (var i = 0; i < length; ++i) { + for (let i = 0; i < length; ++i) { resultSet[array[i]] = true; } } function _parse (resultSet, arg) { if (!arg) return; - var argType = typeof arg; + const argType = typeof arg; // 'foo bar' if (argType === 'string') { @@ -68,18 +68,18 @@ var classNames = (function () { function _classNames () { // don't leak arguments // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments - var len = arguments.length; - var args = Array(len); - for (var i = 0; i < len; i++) { + const length = arguments.length; + const args = Array(len); + for (const i = 0; i < length; i++) { args[i] = arguments[i]; } - var classSet = new StorageObject(); + const classSet = new StorageObject(); _parseArray(classSet, args); - var list = []; + const list = []; - for (var k in classSet) { + for (const k in classSet) { if (classSet[k]) { list.push(k) } diff --git a/index.js b/index.js index ee6bbce..462992c 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,10 @@ -var hasOwn = {}.hasOwnProperty; +const hasOwn = {}.hasOwnProperty; export default function classNames () { - var classes = ''; + let classes = ''; - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; + for (let i = 0; i < arguments.length; i++) { + const arg = arguments[i]; if (arg) { classes = appendClass(classes, parseValue(arg)); } @@ -30,9 +30,9 @@ function parseValue (arg) { return arg.toString(); } - var classes = ''; + let classes = ''; - for (var key in arg) { + for (const key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes = appendClass(classes, key); }