
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
string-incr
Advanced tools
Increment or decrement strings with numbers
A lightweight, zero-dependency utility for incrementing and decrementing strings that contain numbers. Perfect for generating sequential names, slugs, or identifiers.
npm install string-incr
# or
yarn add string-incr
# or
pnpm add string-incr
import { stringIncr, stringDecr } from 'string-incr'
stringIncr('Hello world 42')
//=> 'Hello world 43'
stringIncr('Hello world')
//=> 'Hello world 1'
stringDecr('Hello world 42')
//=> 'Hello world 41'
stringDecr('Hello world 1')
//=> 'Hello world'
const { stringIncr, stringDecr } = require('string-incr')
stringIncr('Hello world 42')
//=> 'Hello world 43'
stringDecr('Hello world 2')
//=> 'Hello world 1'
stringDecr('Hello world 1')
//=> 'Hello world'
stringIncr(str, firstAppend?)Increments a string that ends with a number, or appends a number if none exists.
str (string | number): The string or number to incrementfirstAppend (string | number, optional): The separator/number to use when no number exists (default: ' 1')string: The incremented string// Basic increment
stringIncr('Hello world')
//=> 'Hello world 1'
stringIncr('Hello world 1')
//=> 'Hello world 2'
stringIncr('Hello world 2')
//=> 'Hello world 3'
stringIncr('Hello world 42')
//=> 'Hello world 43'
// Numbers without spaces
stringIncr('Hello world42')
//=> 'Hello world43'
stringIncr('Hello 42 world99')
//=> 'Hello 42 world100'
// With separators
stringIncr('Hello world-42')
//=> 'Hello world-43'
// Custom first append
stringIncr('Hello world', '-1')
//=> 'Hello world-1'
stringIncr('Hello world', '#42')
//=> 'Hello world#42'
stringIncr('Hello world', 42)
//=> 'Hello world 42'
stringIncr('Hello world', 1)
//=> 'Hello world 1'
stringIncr('Hello world', '#')
//=> 'Hello world#1'
// Number input
stringIncr(41)
//=> '42'
// Edge cases
stringIncr('')
//=> '1'
stringDecr(str, removeSeparator?)Decrements a string that ends with a number. When the number reaches 1 or 0, it removes the number entirely.
str (string | number): The string or number to decrementremoveSeparator (string, optional): Separator to remove when number reaches ≤ 1 (only applied at 1 or 0, not during normal decrements)string: The decremented string, or the base string when number reaches ≤ 1// Basic decrement
stringDecr('Hello world 42')
//=> 'Hello world 41'
stringDecr('Hello world 3')
//=> 'Hello world 2'
stringDecr('Hello world 2')
//=> 'Hello world 1'
// Removes number when reaching 1 or 0
stringDecr('Hello world 1')
//=> 'Hello world'
stringDecr('Hello world 0')
//=> 'Hello world'
// No change when no number exists
stringDecr('Hello world')
//=> 'Hello world'
// Numbers without spaces
stringDecr('Hello world42')
//=> 'Hello world41'
stringDecr('Hello 42 world100')
//=> 'Hello 42 world99'
// With separators - keeps separator by default
stringDecr('Hello world-42')
//=> 'Hello world-41'
stringDecr('Hello world-1')
//=> 'Hello world-'
// With separators - remove separator when specified
stringDecr('Hello world-1', '-')
//=> 'Hello world'
stringDecr('Hello world#1', '#')
//=> 'Hello world'
stringDecr('Hello_world_1', '_')
//=> 'Hello_world'
// removeSeparator ONLY applies when number reaches 1 or 0
stringDecr('Hello world-42', '-')
//=> 'Hello world-41' ← separator NOT removed (number > 1)
stringDecr('Hello world-2', '-')
//=> 'Hello world-1' ← separator NOT removed (number > 1)
stringDecr('Hello world-1', '-')
//=> 'Hello world' ← separator removed (number = 1)
// Number input (mathematical operation)
stringDecr(42)
//=> '41'
stringDecr(0)
//=> '-1'
' 1')firstAppend parameter controls what to append when no number existsstringIncr('test-5') → 'test-6' (the - is a separator, not part of the number)stringDecr('test-5') → 'test-4' (extracts 5, decrements to 4)stringDecr('test-1') → 'test-' (removes the 1)stringIncr(-5) → '-4'stringDecr(-5) → '-6'See BEHAVIOR.md for detailed edge cases and design decisions.
file.txt → file 1.txt → file 2.txtmy-post → my-post 1 → my-post 2 (or use stringIncr('my-post', '-1') for my-post-1)version-1 → version-2item-5 → item-4 → item-3 → item-2 → item-1 → itemThis package is written in TypeScript and includes type definitions out of the box.
import { stringIncr, stringDecr } from 'string-incr'
// Full type safety
const result: string = stringIncr('test 1')
# Install dependencies
pnpm install
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Build
pnpm build
# Lint
pnpm lint
# Type check
pnpm typecheck
Version 4.0.0 adds dual ESM/CommonJS support with breaking changes to default behavior. See CHANGELOG.md for full details and migration guide.
MIT © apoutchika
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)FAQs
Increment or decrement strings with numbers
The npm package string-incr receives a total of 20 weekly downloads. As such, string-incr popularity was classified as not popular.
We found that string-incr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.