@jts-studios/utils
v0.1.1
Published
Small utility helpers for JavaScript projects
Readme
JTS Utils
Small utility helpers for JavaScript projects.
Install
npm install @jts-studios/utilsUsage
import { wait, clamp, markdownToHtml } from "@jts-studios/utils"
await wait(250)
console.log(clamp(12, 0, 10))
console.log(await markdownToHtml("# Hello"))Import Patterns (Intuitive API)
You can import utilities in two clean ways.
1) Root imports (best default)
import { wait, fetchText, markdownToHtml, clamp, setTheme, initTheme } from "@jts-studios/utils"2) Subpath imports (when you want very explicit module targeting)
import { wait } from "@jts-studios/utils/async"
import { fetchText } from "@jts-studios/utils/file"
import { markdownToHtml } from "@jts-studios/utils/markdown"
import { clamp } from "@jts-studios/utils/math"
import { setTheme } from "@jts-studios/utils/theme"
import { initTheme } from "@jts-studios/utils/theme-init"Utility Reference
Async
wait(ms: number): Promise<void>
File / Network
fetchText(url: string, init?: RequestInit): Promise<string>
Markdown
markdownToHtml(markdown: string): Promise<string>
Math
clamp(value: number, min: number, max: number): number
Theme (Browser)
setTheme(theme: string): voidinitTheme(defaultTheme = "dark"): void
Project Structure
jts-utils/
src/
index.js # package root entrypoint + barrel exports
async.js
file.js
markdownToHtml.js
math.js
themes.js
themes_init.jsPublishing Wiki
This section is a full guide for publishing and maintaining this package on npm.
Current Package
- Name:
@jts-studios/utils - Registry:
https://registry.npmjs.org/ - Visibility: public
One-Time Setup (Per Machine)
- Install Node.js LTS and npm.
- Verify tooling:
node -v
npm -v- Login to npm:
npm login- Confirm account:
npm whoamiStandard Release Flow
- Make your code changes.
- Bump package version in
package.json:
npm version patchUse one of these depending on release type:
patch→ bug fixes (0.1.0→0.1.1)minor→ backward-compatible features (0.1.0→0.2.0)major→ breaking changes (0.1.0→1.0.0)
- Build package:
npm run build- Check publish contents:
npm run pack:check- Publish:
npm publishAuth Options for Publish
If your npm account enforces stronger security, use one of these:
Option A: OTP publish
npm publish --otp=123456Option B: Granular token (CI or local automation)
Create a granular npm token with package publish permissions and (if required) 2FA bypass for publishing.
npm config set //registry.npmjs.org/:_authToken YOUR_TOKEN
npm publish
npm config delete //registry.npmjs.org/:_authTokenPre-Publish Checklist
npm whoamireturns the expected account- package name/scope is owned by your account or org
- version has not already been published
- build passes (
npm run build) - tarball looks correct (
npm run pack:check)
Verify a Release
npm view @jts-studios/utils versionThen test in another project:
npm install @jts-studios/utilsCommon Errors and Fixes
ENEEDAUTH:- Run
npm loginand retry.
- Run
E403(2FA/token policy issue):- Use
--otp, or use a granular token configured for publishing.
- Use
E404on scoped publish:- Scope/package access is wrong for current account.
- Confirm with
npm whoamiand publish under a scope you own.
You cannot publish over the previously published versions:- Increment version before publishing.
Security Best Practices
- Never commit tokens to git.
- Use short-lived or granular tokens when possible.
- Revoke any token that was exposed in logs/chat.
Notes
- Package name and scope must exist on npm and be owned by your npm account/org.
- For first publish of a scoped package,
publishConfig.accessis set topublicinpackage.json.
