From 596a897afc35a9b8144dee1844e2032032c4b07a Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 6 Feb 2020 11:11:16 +0000 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 87 +++++++++++++++++++++++-------------------- .vscode/launch.json | 29 +++++++++++++++ .vscode/settings.json | 27 +++++++++++++- README.md | 43 --------------------- npmextra.json | 1 + package-lock.json | 42 ++++++++++++--------- package.json | 18 ++++----- ts/lik.fastmap.ts | 11 ++++++ ts/lik.objectmap.ts | 23 ++++++++++++ ts/lik.stringmap.ts | 10 ++--- 10 files changed, 174 insertions(+), 117 deletions(-) create mode 100644 .vscode/launch.json delete mode 100644 README.md create mode 100644 ts/lik.fastmap.ts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a6159b7..a95dfb6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,18 +1,16 @@ # gitzone ci_default image: registry.gitlab.com/hosttoday/ht-docker-node:npmci -variables: - GIT_STRATEGY: clone cache: paths: - - .npmci_cache/ - key: "$CI_BUILD_STAGE" + - .npmci_cache/ + key: '$CI_BUILD_STAGE' stages: -- security -- test -- release -- metadata + - security + - test + - release + - metadata # ==================== # security stage @@ -20,21 +18,23 @@ stages: mirror: stage: security script: - - npmci git mirror + - npmci git mirror tags: - - docker - - notpriv + - lossless + - docker + - notpriv snyk: + image: registry.gitlab.com/hosttoday/ht-docker-node:snyk stage: security script: - npmci npm prepare - - npmci command npm install -g snyk - npmci command npm install --ignore-scripts - npmci command snyk test tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # test stage @@ -43,37 +43,40 @@ snyk: testStable: stage: test script: - - npmci npm prepare - - npmci node install stable - - npmci npm install - - npmci npm test + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - priv + - lossless + - docker + - priv testBuild: stage: test script: - - npmci npm prepare - - npmci node install lts - - npmci npm install - - npmci command npm run build + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv + - lossless + - docker + - notpriv release: stage: release script: - - npmci node install lts - - npmci npm publish + - npmci node install stable + - npmci npm publish only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # metadata stage @@ -83,33 +86,35 @@ codequality: allow_failure: true script: - npmci command npm install -g tslint typescript + - npmci npm prepare - npmci npm install - npmci command "tslint -c tslint.json ./ts/**/*.ts" tags: - - docker - - priv + - lossless + - docker + - priv trigger: stage: metadata script: - - npmci trigger + - npmci trigger only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv pages: - image: hosttoday/ht-docker-dbase:npmci - services: - - docker:18-dind stage: metadata script: + - npmci node install lts - npmci command npm install -g @gitzone/tsdoc - npmci npm prepare - npmci npm install - npmci command tsdoc tags: + - lossless - docker - notpriv only: @@ -117,5 +122,5 @@ pages: artifacts: expire_in: 1 week paths: - - public + - public allow_failure: true diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..112db52 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "current file", + "type": "node", + "request": "launch", + "args": [ + "${relativeFile}" + ], + "runtimeArgs": ["-r", "@gitzone/tsrun"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": "test.ts", + "type": "node", + "request": "launch", + "args": [ + "test/test.ts" + ], + "runtimeArgs": ["-r", "@gitzone/tsrun"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 6649301..01d2b8d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,26 @@ { - "workbench.colorCustomizations": {} -} \ No newline at end of file + "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"] + } + } + } + } + } + } + ] +} diff --git a/README.md b/README.md deleted file mode 100644 index da5049a..0000000 --- a/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# @pushrocks/lik -light little helpers for node - -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/lik) -* [gitlab.com (source)](https://gitlab.com/pushrocks/lik) -* [github.com (source mirror)](https://github.com/pushrocks/lik) -* [docs (typedoc)](https://pushrocks.gitlab.io/lik/) - -## Status for master -[![build status](https://gitlab.com/pushrocks/lik/badges/master/build.svg)](https://gitlab.com/pushrocks/lik/commits/master) -[![coverage report](https://gitlab.com/pushrocks/lik/badges/master/coverage.svg)](https://gitlab.com/pushrocks/lik/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/lik.svg)](https://www.npmjs.com/package/@pushrocks/lik) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/lik/badge.svg)](https://snyk.io/test/npm/@pushrocks/lik) -[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) - -## Usage - -Use TypeScript for best in class instellisense. - -```javascript -// import any tool that you need from lik -import { Stringmap, Objectmap, Observablemap } from 'lik'; -``` - -### class Stringmap - -Stringmap allows you to keep track of strings. It allows you to register triggers for certain events -like when a certain string is removed or added to the map - -### class Objectmap - -Sometimes you need to keep track of objects, but implementing logic for removing, finding or updating is tedious. -Objectmap takes care of keeping track of objects for you. - -For further information read the linked docs at the top of this readme. - -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) - -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) diff --git a/npmextra.json b/npmextra.json index 6bd9078..e81c5cf 100644 --- a/npmextra.json +++ b/npmextra.json @@ -4,6 +4,7 @@ "npmAccessLevel": "public" }, "gitzone": { + "projectType": "npm", "module": { "githost": "gitlab.com", "gitscope": "pushrocks", diff --git a/package-lock.json b/package-lock.json index dcf2405..d721780 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,18 +11,18 @@ "dev": true }, "@babel/code-frame": { - "version": "7.5.5", - "resolved": "https://verdaccio.lossless.one/@babel%2fcode-frame/-/code-frame-7.5.5.tgz", - "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "version": "7.8.3", + "resolved": "https://verdaccio.lossless.one/@babel%2fcode-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", "dev": true, "requires": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.3" } }, "@babel/highlight": { - "version": "7.5.0", - "resolved": "https://verdaccio.lossless.one/@babel%2fhighlight/-/highlight-7.5.0.tgz", - "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "version": "7.8.3", + "resolved": "https://verdaccio.lossless.one/@babel%2fhighlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -536,9 +536,9 @@ "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" }, "@types/node": { - "version": "12.12.14", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.14.tgz", - "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==" + "version": "13.7.0", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz", + "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" }, "@types/through2": { "version": "2.0.34", @@ -1482,9 +1482,9 @@ "dev": true }, "resolve": { - "version": "1.13.1", - "resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.13.1.tgz", - "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", + "version": "1.15.1", + "resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1688,9 +1688,9 @@ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, "tslint": { - "version": "5.20.1", - "resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.20.1.tgz", - "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", + "version": "6.0.0", + "resolved": "https://verdaccio.lossless.one/tslint/-/tslint-6.0.0.tgz", + "integrity": "sha512-9nLya8GBtlFmmFMW7oXXwoXS1NkrccqTqAtwXzdPV9e2mqSEvCki6iHL/Fbzi5oqbugshzgGPk7KBb2qNP1DSA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -1704,8 +1704,16 @@ "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", - "tslib": "^1.8.0", + "tslib": "^1.10.0", "tsutils": "^2.29.0" + }, + "dependencies": { + "tslib": { + "version": "1.10.0", + "resolved": "https://verdaccio.lossless.one/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + } } }, "tslint-config-prettier": { diff --git a/package.json b/package.json index 106c995..faf803d 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "@gitzone/tsrun": "^1.2.8", "@gitzone/tstest": "^1.0.28", "@pushrocks/tapbundle": "^3.2.0", - "@types/node": "^12.12.14", - "tslint": "^5.20.1", + "@types/node": "^13.7.0", + "tslint": "^6.0.0", "tslint-config-prettier": "^1.18.0" }, "dependencies": { @@ -38,14 +38,14 @@ "symbol-tree": "^3.2.4" }, "files": [ - "ts/*", - "ts_web/*", - "dist/*", - "dist_web/*", - "dist_ts_web/*", - "assets/*", + "ts/**/*", + "ts_web/**/*", + "dist/**/*", + "dist_web/**/*", + "dist_ts_web/**/*", + "assets/**/*", "cli.js", "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/ts/lik.fastmap.ts b/ts/lik.fastmap.ts new file mode 100644 index 0000000..1376eb5 --- /dev/null +++ b/ts/lik.fastmap.ts @@ -0,0 +1,11 @@ +import * as plugins from './lik.plugins'; + +export class FastMap { + private mapObject: { [key: string]: T } = {}; + + public isUniqueKey() {} + + public addToMap(identifier: string, objectArg: T) { + this.mapObject[identifier] = objectArg; + } +} diff --git a/ts/lik.objectmap.ts b/ts/lik.objectmap.ts index ee7db7a..314df84 100644 --- a/ts/lik.objectmap.ts +++ b/ts/lik.objectmap.ts @@ -1,4 +1,5 @@ import * as plugins from './lik.plugins'; +import { FastMap } from './lik.fastmap'; export interface IObjectmapForEachFunction { (itemArg: T): void; @@ -12,6 +13,7 @@ export interface IObjectmapFindFunction { * allows keeping track of objects */ export class Objectmap { + private fastMap = new FastMap(); private objectArray: T[] = []; // events @@ -24,6 +26,27 @@ export class Objectmap { // nothing here } + /** + * adds an object mapped to a string + * the string must be unique + */ + addMappedUnique(uniqueKey: string, objectArg: T) { + this.add(objectArg); + this.fastMap.addToMap(uniqueKey, objectArg); + } + + /** + * fastest way to get an object from the map + * @param uniqueKey + */ + public getMappedUnique(uniqueKey: string) {} + + /** + * remove key + * @param functionArg + */ + public removeMappedUnique() {} + /** * add object to Objectmap * returns false if the object is already in the map diff --git a/ts/lik.stringmap.ts b/ts/lik.stringmap.ts index 9114cfa..f6e45d6 100644 --- a/ts/lik.stringmap.ts +++ b/ts/lik.stringmap.ts @@ -24,7 +24,7 @@ export class Stringmap { * like addString, but accepts an array of strings */ addStringArray(stringArrayArg: string[]) { - for (let stringItem of stringArrayArg) { + for (const stringItem of stringArrayArg) { this.addString(stringItem); } } @@ -33,7 +33,7 @@ export class Stringmap { * removes a string from Stringmap */ removeString(stringArg: string) { - for (let keyArg in this._stringArray) { + for (const keyArg in this._stringArray) { if (this._stringArray[keyArg] === stringArg) { this._stringArray.splice(parseInt(keyArg), 1); } @@ -61,7 +61,7 @@ export class Stringmap { */ public checkMinimatch(miniMatchStringArg: string): boolean { let foundMatch: boolean = false; - for (let stringItem of this._stringArray) { + for (const stringItem of this._stringArray) { if (plugins.minimatch(stringItem, miniMatchStringArg)) { foundMatch = true; } @@ -94,7 +94,7 @@ export class Stringmap { */ public registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) { this._triggerUntilTrueFunctionArray.push(() => { - let result = functionArg(); + const result = functionArg(); if (result === true) { doFunctionArg(); } @@ -107,7 +107,7 @@ export class Stringmap { * notifies triggers */ private notifyTrigger() { - let filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => { + const filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => { return !functionArg(); }); this._triggerUntilTrueFunctionArray = filteredArray;