Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@mamba/utils
Advanced tools
@mamba/utils
O pacote @mamba/utils
contém métodos úteis para facilitar o desenvolvimento de aplicativos Mamba.
import * as UI from '@mamba/utils/ui.js';
timeout(delay: Number): Promise
UI.timeout()
move a execução do script para o final da pilha de execução. É uma simples abstração de um setTimeout
que retorna uma Promise
.
import { timeout } from '@mamba/utils/ui.js';
function init() {
console.log('Log imediato');
timeout(300).then(() => {
console.log('Log após 300ms');
});
}
init();
Com isso, é possível utilizar async/await
para facilitar a leitura de alguns métodos:
import { timeout } from '@mamba/utils/ui.js';
async function init() {
console.log('Log imediato');
await timeout(300);
console.log('Log após 300ms');
}
init();
import * as Money from '@mamba/utils/money.js';
format(value: Number): string
Money.format()
formata um valor númerico para um formato de dinheiro:
import { format } from '@mamba/utils/money.js';
format(100); // '100,00'
format(1000); // '1.000,00'
format(100000); // '100.000,00'
format(1000000.27); // '1.000.000,27'
padZero(value: Number | string): string
Money.padZero()
adiciona um 0
para valores numéricos menores que 10
or strings de tamanho 1
.
import { padZero } from '@mamba/utils/money.js';
padZero(1); // '01'
padZero('2'); // '02'
padZero(17); // '17'
padZero('230'); // '230'
round(value: Number): Number
ceil(value: Number): Number
floor(value: Number): Number
Money.round()
, Money.ceil()
, Money.floor()
são similares aos métodos Math.*
de mesmo nome. A principal diferença é que lidam com alguns erros de arrendondamento da linguagem e levam em conta o valor decimal.
import { round, ceil, floor } from '@mamba/utils/money.js';
Math.round(1.005); // 1
round(1.005); // 1.01
Math.floor(127.77 / 10); // 12
floor(127.77 / 10); // 12.77
Math.ceil(127.77 / 10); // 13
ceil(127.77 / 10); // 12.78
import * as DateUtils from '@mamba/utils/date.js';
format(date: Date, mask: string): string
DateUtils.format()
recebe um objeto Date
retorna a data formatada de acordo com a string
de máscara passada.
Os tokens
suportados são:
import { format } from '@mamba/utils/date.js';
format(new Date(2019, 1, 20), 'dd/mm/yyyy')) // 20/02/2019
format(new Date(2019, 1, 20, 20, 30, 55), 'HH:MM:ss')) // 20:30:55
FAQs
Utility methods for mamba apps
We found that @mamba/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.