Skip to content

Commit 7d00883

Browse files
committed
🦦 update package for deno & npm
1 parent d14974a commit 7d00883

10 files changed

Lines changed: 121 additions & 704 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Copyright (C) 2025 Subhajit Sahu
2-
# SPDX-License-Identifier: AGPL-3.0-or-later
3-
# See LICENSE for full terms
4-
51
name: CI
62
on:
73
push:
@@ -30,16 +26,23 @@ jobs:
3026
- uses: denoland/setup-deno@v2
3127
with:
3228
deno-version: v2.x
33-
- run: deno test
29+
- run: deno test --allow-read
3430

3531

36-
publish:
37-
name: Publish package
32+
publish-jsr:
33+
name: Publish packages
3834
needs: [test]
3935
runs-on: ubuntu-latest
4036
permissions:
4137
contents: write
4238
id-token: write
4339
steps:
4440
- uses: actions/checkout@v4
41+
- uses: denoland/setup-deno@v2
42+
with:
43+
deno-version: v2.x
44+
- uses: nodef/npm-config.action@v1.2.0
45+
with:
46+
credentials: auto
4547
- run: npx jsr publish
48+
- run: deno -A build.ts --publish-core

‎.github/workflows/pr.yml‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Copyright (C) 2025 Subhajit Sahu
2-
# SPDX-License-Identifier: AGPL-3.0-or-later
3-
# See LICENSE for full terms
4-
51
name: PR
62
on: [pull_request]
73
env:
@@ -20,4 +16,4 @@ jobs:
2016
- uses: denoland/setup-deno@v2
2117
with:
2218
deno-version: v2.x
23-
- run: deno test
19+
- run: deno test --allow-read

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Generated files
22
.build/
3-
*.d.ts
43
*.map
54

65
# Logs

‎LICENSE‎

Lines changed: 21 additions & 661 deletions
Large diffs are not rendered by default.

‎README.md‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
<!-- Copyright (C) 2025 Subhajit Sahu -->
2-
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
3-
<!-- See LICENSE for full terms -->
4-
5-
A [string] is a sequence of characters. In JavaScript, strings are not [mutable]. Any transfomation of a *string*, such as `slice` or `concat` generates a *new string*. The *JavaScript runtime* however may optimize this behavior by *mutating strings behind the scenes*, when it can be guarenteed that the previous string is *not accessible* to the programmer. The *runtime* may also *avoid copying slices* of a string, or even *concatenation of slices of* *strings*, by implementing it as a *series of lookups into existing strings*. Food for thought.
6-
7-
This package provides **functions** for generating spaces, querying *about* a string, *comparing* strings, getting *parts* of a string, *searching* a string, *transforming* a string or its *case*, finding *ngrams* in strings, finding *similarity/distance* between strings, and array-like functions. All **built-in** string functions are also included. Finally, *constants* for *ASCII characters*, and *minimum/maximum code point* are included.
1+
A [string] is a sequence of characters.
82

93
▌
104
📦 [JSR](https://jsr.io/@nodef/extra-string),
5+
📦 [NPM](https://www.npmjs.com/package/extra-string),
116
📰 [Docs](https://jsr.io/@nodef/extra-string/doc).
127

8+
In JavaScript, strings are not [mutable]. Any transfomation of a *string*, such as `slice` or `concat` generates a *new string*. The *JavaScript runtime* however may optimize this behavior by *mutating strings behind the scenes*, when it can be guarenteed that the previous string is *not accessible* to the programmer. The *runtime* may also *avoid copying slices* of a string, or even *concatenation of slices of* *strings*, by implementing it as a *series of lookups into existing strings*. Food for thought.
9+
10+
This package provides **functions** for generating spaces, querying *about* a string, *comparing* strings, getting *parts* of a string, *searching* a string, *transforming* a string or its *case*, finding *ngrams* in strings, finding *similarity/distance* between strings, and array-like functions. All **built-in** string functions are also included. Finally, *constants* for *ASCII characters*, and *minimum/maximum code point* are included.
11+
1312
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
1413
[mutable]: https://developer.mozilla.org/en-US/docs/Glossary/Mutable
15-
[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-string.web/index.js
1614

1715
<br>
1816

@@ -190,14 +188,6 @@ xstring.tverskyDistance('pikachu', 'raichu', 3, 0.2, 0.4);
190188
<br>
191189

192190

193-
## License
194-
195-
As of 26 June 2025, this project is licensed under AGPL-3.0. Previous versions remain under MIT.
196-
197-
<br>
198-
<br>
199-
200-
201191
[![](https://raw.githubusercontent.com/qb40/designs/gh-pages/0/image/11.png)](https://wolfram77.github.io)<br>
202192
[![ORG](https://img.shields.io/badge/org-nodef-green?logo=Org)](https://nodef.github.io)
203193
![](https://ga-beacon.deno.dev/G-RC63DPBH3P:SH3Eq-NoQ9mwgYeHWxu7cw/github.com/nodef/extra-string)

‎build.ts‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {parseArgs} from "@std/cli/parse-args";
2+
3+
4+
// Run a command in a subprocess, with inherited stdio.
5+
async function run(command: string, args: string[], cwd?: string) {
6+
const cmd = new Deno.Command(command, {
7+
args: args,
8+
cwd: cwd,
9+
stdin: 'inherit',
10+
stdout: 'inherit',
11+
stderr: 'inherit'
12+
});
13+
return await cmd.spawn().status;
14+
}
15+
16+
17+
// Publish core package to npm.
18+
async function publishCoreToNpm() {
19+
const name = JSON.parse(await Deno.readTextFile('deno.json')).name.replace(/^@nodef\//, '');
20+
console.log(`Publishing the ${name} package to npm...`);
21+
await run('deno', ['pack', '--output', `${name}.tgz`, '--allow-dirty']);
22+
Deno.mkdirSync('.temp-pack', {recursive: true});
23+
await run('tar', ['-xzf', `${name}.tgz`, '-C', '.temp-pack']);
24+
Deno.removeSync(`${name}.tgz`);
25+
const meta = JSON.parse(await Deno.readTextFile('.temp-pack/package/package.json'));
26+
meta.name = name;
27+
await Deno.writeTextFile('.temp-pack/package/package.json', JSON.stringify(meta, null, 2));
28+
await run('npm', ['publish', '--access', 'public'], '.temp-pack/package');
29+
await Deno.remove('.temp-pack', {recursive: true});
30+
}
31+
32+
33+
// Main function, of course.
34+
async function main() {
35+
const args = parseArgs(Deno.args, {
36+
boolean: ['publish-core'],
37+
default: {'publish-core': false}
38+
});
39+
if (args['publish-core']) {
40+
await publishCoreToNpm();
41+
}
42+
}
43+
main();

‎deno.json‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"name": "@nodef/extra-string",
3-
"version": "0.2.3",
4-
"license": "AGPL-3.0",
3+
"version": "2.4.2",
4+
"license": "MIT",
55
"exports": "./index.ts",
6-
"exclude": [".github/"]
6+
"exclude": [".github/"],
7+
"imports": {
8+
"@std/assert": "jsr:@std/assert@^1.0.19",
9+
"@std/cli": "jsr:@std/cli@^1.0.32"
10+
}
711
}

‎deno.lock‎

Lines changed: 32 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎index.test.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// Copyright (C) 2025 Subhajit Sahu
2-
// SPDX-License-Identifier: AGPL-3.0-or-later
3-
// See LICENSE for full terms
4-
5-
import {assert, assertEquals} from "jsr:@std/assert";
1+
import {assert, assertEquals} from "@std/assert";
62
import * as xstring from "./index.ts";
73
import {
84
type ReplaceFunction,

‎index.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// Copyright (C) 2025 Subhajit Sahu
2-
// SPDX-License-Identifier: AGPL-3.0-or-later
3-
// See LICENSE for full terms
4-
51
//#region CONSTANTS
62
/** Decimal digits 0-9. */
73
export const DIGITS: string = "0123456789";

0 commit comments

Comments
 (0)