24 Commits

Author SHA1 Message Date
677c8e3fe7 3.0.8 2024-02-29 13:50:00 +01:00
b6d5db4605 fix(core): update 2024-02-29 13:49:59 +01:00
0f802e223e 3.0.7 2024-02-29 13:31:34 +01:00
d5438aaaab fix(core): update 2024-02-29 13:31:33 +01:00
4516a1e8ba 3.0.6 2023-08-15 11:32:47 +02:00
00e4d35c55 fix(core): update 2023-08-15 11:32:46 +02:00
039a4ded96 3.0.5 2020-06-05 09:11:49 +00:00
3448b8cf97 fix(core): update 2020-06-05 09:11:48 +00:00
328fccc086 3.0.4 2020-06-05 01:26:58 +00:00
201e08e10e fix(core): update 2020-06-05 01:26:58 +00:00
1ee8930525 3.0.3 2020-03-05 20:41:15 +00:00
6a8fca75c9 fix(core): update 2020-03-05 20:41:15 +00:00
b2f0b8fc3d 3.0.2 2020-03-05 20:39:45 +00:00
20a16aef32 fix(core): update 2020-03-05 20:39:44 +00:00
45d8752a71 3.0.1 2018-10-06 17:01:11 +02:00
d82651c031 fix(core): update 2018-10-06 17:01:10 +02:00
6b89c93165 3.0.0 2018-10-06 15:38:55 +02:00
17ecde59d5 BREAKING CHANGE(scope): update scope 2018-10-06 15:38:55 +02:00
79f78550ba 2.0.0 2017-07-17 17:01:16 +02:00
d29fd78753 refactor method names 2017-07-17 17:01:10 +02:00
74b52173dd 1.0.4 2017-07-14 18:54:09 +02:00
8f63394641 now working 2017-07-14 18:53:10 +02:00
9a1efb9940 1.0.3 2017-07-14 17:18:31 +02:00
2d02a3c7d9 initial 2017-07-14 17:18:27 +02:00
14 changed files with 6245 additions and 8 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

20
.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

17
npmextra.json Normal file
View File

@ -0,0 +1,17 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "smartunique",
"description": "make things unique",
"npmPackagename": "@push.rocks/smartunique",
"license": "MIT"
}
}
}

View File

@ -1,18 +1,56 @@
{
"name": "smartunique",
"version": "1.0.2",
"name": "@push.rocks/smartunique",
"version": "3.0.8",
"private": false,
"description": "make things unique",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "https://gitlab.com/pushrocks/smartunique.git"
},
"keywords": [
"unique",
"key",
"uuid",
"shortid",
"lossless",
"pushrocks",
"TypeScript"
],
"devDependencies": {
"tapbundle": "^1.0.13"
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.8",
"@types/node": "^20.5.0"
},
"dependencies": {
"typings-global": "^1.0.16"
}
"@types/uuid": "^9.0.2",
"nanoid": "^4.0.2",
"uuid": "^9.0.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
]
}

5793
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

53
readme.md Normal file
View File

@ -0,0 +1,53 @@
# @push.rocks/smartunique
make things unique
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartunique)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartunique)
* [github.com (source mirror)](https://github.com/push.rocks/smartunique)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartunique/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartunique/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartunique/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartunique)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartunique)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartunique)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartunique)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartunique)](https://lossless.cloud)
## Usage
Use TypeScript for best in class instellisense.
```javascript
// We are using TypeScript syntax here to have types in place
import * as smartunique from 'smartunique';
// creates a short mathematically highly unique short string
let myShortid = smartunique.shortid();
// creates a string that is possibly unique world wide
let myUuid4 = smartunique.uuid4();
// creates a oneway repeatable unique id within a certain namespace
let myUuid5 = smartunique.uuid('myobscureduser@somedomain.com', smartunique.uuid4());
```
Learn more about UUIDs: knowledgebase.gitzone.com/uuid.html
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)

31
test/test.ts Normal file
View File

@ -0,0 +1,31 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartunique from '../ts/index.js';
tap.test('should create shortid', async () => {
const result = smartunique.shortId();
console.log(result);
const result2 = smartunique.shortId(8);
console.log(result2);
});
tap.test('should create uuidv4', async () => {
const result = smartunique.uuid4();
console.log(result);
});
tap.test('should create uuidv5', async () => {
const result = smartunique.uuid5('sometext');
console.log(result);
});
tap.test('should create uuidv5 within namespace', async () => {
const result = smartunique.uuid5('sometext', smartunique.uuid4());
console.log(result);
});
tap.test('should create a uni string', async () => {
const result = smartunique.uni();
console.log(result);
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartunique',
version: '3.0.8',
description: 'make things unique'
}

35
ts/index.ts Normal file
View File

@ -0,0 +1,35 @@
import * as plugins from './smartunique.plugins.js';
/**
* returns short strings that are unique to very high degree od certainty
*/
export const shortId = (sizeArg?: number): string => {
return plugins.nanoid.nanoid(sizeArg);
};
/**
* returns strings that are unique to a very high degree of certainty
*/
export const uuid4 = (): string => {
return plugins.uuid.v4();
};
export const uuid5 = (customStringArg: string, namespaceArg = plugins.uuid.v5.DNS): string => {
return plugins.uuid.v5(customStringArg, namespaceArg);
};
export const uni = (prefix: string = 'uni', lengthArg = 24) => {
return `${prefix}_${'x'.repeat(lengthArg).replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
})}`;
};
export const uniSimple = (prefix: string = 'uni', lengthArg = 8) => {
return `${prefix}${'x'.repeat(lengthArg).replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
})}`;
};

View File

@ -0,0 +1,4 @@
import * as nanoid from 'nanoid';
import * as uuid from 'uuid';
export { nanoid, uuid };

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}