npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@luriquepro/common-node-utils

v1.0.1

Published

Biblioteca de funções utilitárias para projetos Node/TypeScript

Downloads

27

Readme

@luriquepro/common-node-utils

Biblioteca de funções utilitárias para projetos Node/TypeScript, organizada com Clean Architecture e Clean Code.

Instalação

npm (registry público)

npm install @luriquepro/common-node-utils

Nexus ou registry privado

npm install @luriquepro/common-node-utils --registry=https://seu-nexus.com/repository/npm-hosted/

Ou no .npmrc do projeto:

registry=https://seu-nexus.com/repository/npm-hosted/

Uso

PaginateHelper

import { PaginateHelper } from '@luriquepro/common-node-utils';

const items = [1, 2, 3, 4, 5, 6, 7];
PaginateHelper.paginate(items, 2, 2); // [3, 4]
PaginateHelper.clamp(15, 0, 10);      // 10

FormatterHelper

import { FormatterHelper } from '@luriquepro/common-node-utils';

FormatterHelper.ParseBoolean('true');           // true
FormatterHelper.ParseNumber('42,5');            // 42.5
FormatterHelper.ParseToBRL(1234.56);           // "R$ 1.234,56"
FormatterHelper.FormatMessage('Olá {{ name }}', { name: 'Luiz' });
FormatterHelper.TransformToSnakeCase({ fooBar: 1 });
FormatterHelper.GetUnixTime(new Date());
FormatterHelper.FormatChatId('11987654321');     // "[email protected]"

ValidateHelper

import { ValidateHelper, DOCUMENT_TYPE_ENUM } from '@luriquepro/common-node-utils';

ValidateHelper.IsValidCpf('123.456.789-09');
ValidateHelper.IsValidCnpj('11.222.333/0001-81');
ValidateHelper.IsValidEmail('[email protected]');
ValidateHelper.IsValidPhone('11987654321');
ValidateHelper.IsValidRg('12.345.678-9');
ValidateHelper.GetDocumentTypeByNumber('12345678901'); // DOCUMENT_TYPE_ENUM.CPF

CleanHelper

import { CleanHelper } from '@luriquepro/common-node-utils';

CleanHelper.CleanNumber('R$ 1.234,56');      // "123456"
CleanHelper.CleanString('  foo   bar  ');    // "foo bar"
CleanHelper.CleanDocument('123.456.789-09');  // "12345678909"
CleanHelper.CleanCep('12345-678');           // "12345678"
CleanHelper.CleanPhone('(11) 98765-4321');   // "11987654321"
CleanHelper.CleanAlpha('abc123!');           // "abc"
CleanHelper.CleanAlphaNumeric('a1 b2-c3');   // "a1b2c3"

IdHelper

import { IdHelper } from '@luriquepro/common-node-utils';

IdHelper.GenerateSecureId(12);                    // string aleatória segura
IdHelper.RandomAlphaNumString(6);                 // ex: "A3B9K2"
await IdHelper.GenerateUniqueId(async (id) => false); // ID único (callback verifica existência)

AsyncHelper

import { AsyncHelper } from '@luriquepro/common-node-utils';

await AsyncHelper.Sleep(1000); // aguarda 1 segundo

AuthHelper

import { AuthHelper } from '@luriquepro/common-node-utils';

AuthHelper.RolesCanAccess(['ADMIN', 'EDITOR'], userRoles);  // role ADMIN libera tudo
AuthHelper.CheckPermissions(requiredPerms, userPerms, true); // anyPermission

Helpers específicos para MongoDB

Use o subpath @luriquepro/common-node-utils/mongo:

import { MongoAggregateHelper } from '@luriquepro/common-node-utils/mongo';

MongoAggregateHelper.SearchStep(options);
MongoAggregateHelper.SortStep(options);
MongoAggregateHelper.PaginationSkipStep(options);
MongoAggregateHelper.BuildResponse(result);

Tipos (CommonNodeUtils)

import type { CommonNodeUtils } from '@luriquepro/common-node-utils';

const sort: CommonNodeUtils.Sort = { createdAt: -1 };
const opts: CommonNodeUtils.IQueryOptions = { pagination: { pageNumber: 1, quantityPerPage: 10 }, sort: {} };

Importar funções individuais

import { parseBoolean, isValidCpf, cleanNumber, sleep } from '@luriquepro/common-node-utils';

Estrutura

| Helper | Descrição | |--------|-----------| | PaginateHelper | Paginação, clamp, query options, infinite scroll | | SortHelper | Ordenação (ex.: por data) | | FormatterHelper | Parse (boolean, number, BRL), format message, snake_case, unix time, chat id | | ValidateHelper | CPF, CNPJ, e-mail, telefone, RG, tipo de documento | | CleanHelper | Limpar número, string, documento, CEP, telefone, alpha | | IdHelper | IDs seguros, únicos, string alfanumérica aleatória | | AsyncHelper | Sleep (Promise) | | AuthHelper | Roles e permissões | | MongoAggregateHelper | Pipelines MongoDB (subpath /mongo) |


Publicar o pacote

No npm público (registry.npmjs.org)

Pacote com escopo (@luriquepro/...) precisa de --access=public na primeira publicação:

npm login
npm version patch   # 1.0.0 → 1.0.1 (ou minor/major)
npm publish --access=public

No Nexus (registry privado)

  1. Defina o registry na hora de publicar:
npm login --registry=https://seu-nexus.com/repository/npm-hosted/
npm version patch
npm publish --registry=https://seu-nexus.com/repository/npm-hosted/
  1. Ou use publishConfig no package.json (só para esse pacote):
"publishConfig": {
  "registry": "https://seu-nexus.com/repository/npm-hosted/"
}

Depois: npm login --registry=... e npm publish.


Versionamento

O projeto segue Semantic Versioning (MAJOR.MINOR.PATCH).

Desenvolvimento

npm install
npm run build

Licença

MIT