🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@uoctamika/libraryjs

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uoctamika/libraryjs - npm Package Compare versions

Comparing version
1.1.2
to
1.1.3
+20
-23
dist/cjs/stdio/printf.js

@@ -5,2 +5,5 @@ "use strict";

const util_1 = require("util");
const VALID_SPECIFIERS = new Set([
's', 'd', 'i', 'f', 'c', 'o', 'O', 'x', 'X', 'b', 'j', '%'
]);
function formatArg(arg, specifier) {

@@ -24,32 +27,26 @@ switch (specifier) {

function printf(format, ...args) {
let output = '';
const parts = [];
let argIndex = 0;
let i = 0;
const len = format.length;
const validSpecifiers = ['s', 'd', 'i', 'f', 'c', 'o', 'O', 'x', 'X', 'b', 'j', '%'];
while (i < len) {
if (format[i] === '%') {
if (i + 1 < len) {
const spec = format[i + 1];
if (spec === '%') {
output += '%';
i += 2;
continue;
}
if (validSpecifiers.includes(spec)) {
const value = args[argIndex++];
output += formatArg(value, spec);
i += 2;
continue;
}
const ch = format[i];
if (ch === '%' && i + 1 < len) {
const spec = format[i + 1];
if (spec === '%') {
parts.push('%');
i += 2;
continue;
}
output += format[i];
i++;
if (VALID_SPECIFIERS.has(spec)) {
const value = args[argIndex++];
parts.push(formatArg(value, spec));
i += 2;
continue;
}
}
else {
output += format[i];
i++;
}
parts.push(ch);
i++;
}
process.stdout.write(output);
process.stdout.write(parts.join(''));
}
import { inspect } from 'util';
const VALID_SPECIFIERS = new Set([
's', 'd', 'i', 'f', 'c', 'o', 'O', 'x', 'X', 'b', 'j', '%'
]);
function formatArg(arg, specifier) {

@@ -20,32 +23,26 @@ switch (specifier) {

export function printf(format, ...args) {
let output = '';
const parts = [];
let argIndex = 0;
let i = 0;
const len = format.length;
const validSpecifiers = ['s', 'd', 'i', 'f', 'c', 'o', 'O', 'x', 'X', 'b', 'j', '%'];
while (i < len) {
if (format[i] === '%') {
if (i + 1 < len) {
const spec = format[i + 1];
if (spec === '%') {
output += '%';
i += 2;
continue;
}
if (validSpecifiers.includes(spec)) {
const value = args[argIndex++];
output += formatArg(value, spec);
i += 2;
continue;
}
const ch = format[i];
if (ch === '%' && i + 1 < len) {
const spec = format[i + 1];
if (spec === '%') {
parts.push('%');
i += 2;
continue;
}
output += format[i];
i++;
if (VALID_SPECIFIERS.has(spec)) {
const value = args[argIndex++];
parts.push(formatArg(value, spec));
i += 2;
continue;
}
}
else {
output += format[i];
i++;
}
parts.push(ch);
i++;
}
process.stdout.write(output);
process.stdout.write(parts.join(''));
}
{
"name": "@uoctamika/libraryjs",
"version": "1.1.2",
"version": "1.1.3",
"description": " A lightweight JavaScript & TypeScript utility library - just import and use. No configuration needed, functions are ready to use",

@@ -19,10 +19,7 @@ "main": "./dist/cjs/index.js",

"scripts": {
"build": "npm run clean && npm run build:cjs && npm run build:esm",
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run rename:mjs",
"build:cjs": "tsc -p tsconfig.json",
"build:esm": "tsc -p tsconfig.esm.json && npm run rename:mjs",
"build:esm": "tsc -p tsconfig.esm.json",
"rename:mjs": "find dist/esm -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\; && find dist/esm -name '*.mjs' -exec sed -i \"s/from '\\\\(.*\\\\)\\\\.js'/from '\\\\1.mjs'/g\" {} \\;",
"clean": "rm -rf dist",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src --ext .ts",
"format": "prettier --write \"src/**/*.ts\""
"clean": "rm -rf dist"
},

@@ -57,5 +54,2 @@ "repository": {

"@types/node": "^25.9.1",
"@typescript-eslint/eslint-plugin": "^8.60.0",
"@typescript-eslint/parser": "^8.60.0",
"eslint": "^10.4.1",
"prettier": "^3.8.3",

@@ -62,0 +56,0 @@ "typescript": "^6.0.3"

@@ -54,3 +54,3 @@ # libraryjs

<br>
const {stdio } = require('@uoctamika/libraryjs');

@@ -57,0 +57,0 @@ stdio.printf(format: string, ...args: any[]): void;