Registry / serialization / name-initials

name-initials

JSON →
library0.1.3jsnpmunverified

The `name-initials` package is a lightweight JavaScript utility library designed to efficiently extract initials from various name formats. Currently at version 0.1.3, it provides a simple function that takes a string name as input and returns a string of initials. The library demonstrates robust handling of complex name structures, including single names, multi-part names, hyphenated names, names with common prefixes (like 'de'), and names containing parenthetical remarks. Its core differentiator lies in its opinionated parsing logic, which focuses on extracting the primary initials (typically from the first and last significant name parts), as illustrated by its extensive examples. Given its low version number and focused scope, it is likely a stable, low-maintenance package with infrequent updates, primarily functioning as a utility without significant dependencies. It is released under the permissive MIT license.

npm install name-initials
INSTALL
IMPORT
SIG · NAME-INITIALS
N
name-initials
serializationjavascriptv0.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nameInitials
import nameInitials from 'name-initials';
import { nameInitials } from 'name-initials';
The library exports a default function. Do not use named import syntax.
nameInitials
const nameInitials = require('name-initials');
const { nameInitials } = require('name-initials');
For CommonJS environments, the module exports directly as the default function.

This quickstart demonstrates how to import and use the `nameInitials` function with various name formats, showcasing its ability to correctly extract initials even from complex inputs.

import nameInitials from 'name-initials'; // Example 1: Basic name const initials1 = nameInitials('John Smith'); console.log(`'John Smith' -> ${initials1}`); // Output: JS // Example 2: Name with prefixes and multiple parts const initials2 = nameInitials('Eric A. de Vera-Perez'); console.log(`'Eric A. de Vera-Perez' -> ${initials2}`); // Output: ED // Example 3: Name with parenthetical content const initials3 = nameInitials('Eric (Instructor Somewhere) Vera'); console.log(`'Eric (Instructor Somewhere) Vera' -> ${initials3}`); // Output: EV // Example 4: Single name const initials4 = nameInitials('Maria'); console.log(`'Maria' -> ${initials4}`); // Output: M
Debug
Known issues
gotchaThe library, currently at version 0.1.3, is still in its early development stages. While functional, API stability could change in future minor or patch releases, though its simple scope makes drastic changes less likely.
fix
Review release notes for breaking changes before upgrading. For production, consider pinning to a specific patch version.
affects: <=0.1.3
gotchaThe `name-initials` library implements an opinionated logic for initial extraction, particularly for names with multiple middle components or prefixes. For instance, 'Eric A. E. Vera' yields 'EV' (first and last significant part), not 'EAEV'. This behavior is by design but may differ from expectations for full-name initial extraction.
fix
Always test with a representative set of names to ensure the library's parsing logic aligns with your specific requirements. Refer to the 'Input => Output' section in the README for detailed examples.
affects: >=0.1.0
gotchaThis package does not ship with official TypeScript type definitions. Users working in TypeScript projects will need to either provide their own declaration file (`.d.ts`) or rely on implicit `any` types.
fix
Create a `name-initials.d.ts` file with `declare module 'name-initials' { function nameInitials(name: string): string; export default nameInitials; }` or install `@types/name-initials` if it becomes available.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: nameInitials is not a function
Attempting to use `nameInitials` after an incorrect import, specifically trying a named import (`import { nameInitials } from 'name-initials';`) when the module provides a default export.
fix
Use the correct default import syntax: `import nameInitials from 'name-initials';` (ESM) or `const nameInitials = require('name-initials');` (CommonJS).
Error: Cannot find module 'name-initials'
The package has not been installed, or there is a typo in the import path.
fix
Ensure the package is installed via `npm install name-initials` or `yarn add name-initials`. Verify the import path is exactly `'name-initials'`.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
name-initials — npm install name-initials · libregistry