![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
generic-names
Advanced tools
The `generic-names` package is a utility for generating generic names based on a pattern. It is commonly used in the context of CSS module development to create consistent and unique class names based on the file name and local name (class name) to avoid naming collisions. This package allows developers to customize the naming convention, making it a flexible tool for managing CSS class names in a modular fashion.
Generating generic names
This feature demonstrates how to generate a generic name using the `generic-names` package. The `generate` function takes a pattern and options as arguments. The pattern includes placeholders like `[name]`, `[local]`, and `[hash:base64:5]` which are replaced with the file name, local name (class name), and a hash respectively. The `context` option specifies the directory to consider as the root for relative paths. The generated name is unique and consistent, making it suitable for use as a CSS class name in modular CSS systems.
const generate = require('generic-names');
const nameGenerator = generate('[name]__[local]___[hash:base64:5]', { context: process.cwd() });
console.log(nameGenerator('className', '/path/to/file.css'));
The `classnames` package is a utility for conditionally joining classNames together. Unlike `generic-names`, which is focused on generating unique class names based on a pattern, `classnames` is used to dynamically construct class names based on the state of the application. It's more about managing class names in the runtime rather than generating them based on a static pattern.
The `css-loader` package is part of Webpack's loader system, and it interprets `@import` and `url()` like import/require() and will resolve them. It also has features for modularizing CSS by local scoping class names. While `css-loader` and `generic-names` both deal with CSS modules and class names, `css-loader` is more comprehensive, handling the loading and processing of CSS files, whereas `generic-names` focuses solely on generating names.
Helper for building generic names, similar to webpack. Designed to be used with postcss‑modules‑scope.
Uses interpolateName from the webpack/loader-utils.
var genericNames = require('generic-names');
var generate = genericNames('[name]__[local]___[hash:base64:5]', {
context: process.cwd()
});
generate('foo', '/case/source.css'); // 'source__foo___3mRq8'
FAQs
Helper for building generic names, similar to webpack
The npm package generic-names receives a total of 330,106 weekly downloads. As such, generic-names popularity was classified as popular.
We found that generic-names demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.