Skip to content

Commit

Permalink
use let/const
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens authored Dec 29, 2023
1 parent db9a9d8 commit 2ce6d7b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
12 changes: 6 additions & 6 deletions bind.js
Original file line number Diff line number Diff line change
@@ -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));
}
Expand All @@ -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);
}
Expand Down
28 changes: 14 additions & 14 deletions dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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') {
Expand All @@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -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));
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 2ce6d7b

Please sign in to comment.