Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fela-utils

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-utils - npm Package Compare versions

Comparing version 5.0.5 to 6.0.0

29

es/generateClassName.js
var chars = 'abcdefghijklmnopqrstuvwxyz';
var charLength = chars.length;
export default function generateClassName(id) {
export default function generateClassName(getId) {
var filterClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
return true;
};
var startId = getId();
var generatedClassName = generateUniqueClassName(startId);
if (!filterClassName(generatedClassName)) {
return generateClassName(getId, filterClassName);
}
return generatedClassName;
}
function generateUniqueClassName(id) {
var className = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var filterClassName = arguments[2];
if (id <= charLength) {
var generatedClassName = chars[id - 1] + className;
var hasFilter = typeof filterClassName === 'function';
if (hasFilter && !filterClassName(generatedClassName)) {
return generateClassName(id + 1, className, filterClassName);
}
return generatedClassName;
return chars[id - 1] + className;
}

@@ -21,3 +28,3 @@

// https://jsperf.com/math-floor-vs-math-round-vs-parseint/55
return generateClassName(id / charLength | 0, chars[id % charLength] + className, filterClassName);
return generateUniqueClassName(id / charLength | 0, chars[id % charLength] + className);
}

@@ -10,15 +10,22 @@ 'use strict';

function generateClassName(id) {
function generateClassName(getId) {
var filterClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
return true;
};
var startId = getId();
var generatedClassName = generateUniqueClassName(startId);
if (!filterClassName(generatedClassName)) {
return generateClassName(getId, filterClassName);
}
return generatedClassName;
}
function generateUniqueClassName(id) {
var className = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var filterClassName = arguments[2];
if (id <= charLength) {
var generatedClassName = chars[id - 1] + className;
var hasFilter = typeof filterClassName === 'function';
if (hasFilter && !filterClassName(generatedClassName)) {
return generateClassName(id + 1, className, filterClassName);
}
return generatedClassName;
return chars[id - 1] + className;
}

@@ -28,3 +35,3 @@

// https://jsperf.com/math-floor-vs-math-round-vs-parseint/55
return generateClassName(id / charLength | 0, chars[id % charLength] + className, filterClassName);
return generateUniqueClassName(id / charLength | 0, chars[id % charLength] + className);
}
{
"name": "fela-utils",
"version": "5.0.5",
"version": "6.0.0",
"description": "Internal utilities for Fela",

@@ -26,4 +26,4 @@ "main": "lib/index.js",

"devDependencies": {
"fela": "^5.1.0"
"fela": "^5.1.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc