Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
8d660a8573 | |||
596a897afc | |||
e1442b1bc8 | |||
2ca9e14f76 | |||
e65f36dfa2 | |||
adb95cd683 | |||
d2106690b4 | |||
2ea5111eb8 | |||
aae10344fe | |||
52b65d7dc3 | |||
1135b418cb | |||
2eb1dbd0b3 |
@ -4,13 +4,13 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -20,17 +20,19 @@ mirror:
|
|||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
snyk:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@ -38,38 +40,41 @@ snyk:
|
|||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- priv
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@ -81,9 +86,11 @@ codequality:
|
|||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
@ -94,20 +101,20 @@ trigger:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:18-dind
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
25
.vscode/settings.json
vendored
25
.vscode/settings.json
vendored
@ -1,3 +1,26 @@
|
|||||||
{
|
{
|
||||||
"workbench.colorCustomizations": {}
|
"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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
43
README.md
43
README.md
@ -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
|
|
||||||
[](https://gitlab.com/pushrocks/lik/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/lik/commits/master)
|
|
||||||
[](https://www.npmjs.com/package/@pushrocks/lik)
|
|
||||||
[](https://snyk.io/test/npm/@pushrocks/lik)
|
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
[](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.html)
|
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
@ -4,6 +4,7 @@
|
|||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
|
1413
package-lock.json
generated
1413
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/lik",
|
"name": "@pushrocks/lik",
|
||||||
"version": "3.0.7",
|
"version": "3.0.14",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "light little helpers for node",
|
"description": "light little helpers for node",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -20,30 +20,30 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
"homepage": "https://gitlab.com/pushrocks/lik#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.3",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.1.17",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.18",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
"@types/node": "^10.12.12",
|
"@types/node": "^13.7.0",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.0.0",
|
||||||
"tslint-config-prettier": "^1.17.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.2",
|
"@pushrocks/smartdelay": "^2.0.6",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@pushrocks/smartrx": "^2.0.3",
|
"@pushrocks/smartrx": "^2.0.5",
|
||||||
"@pushrocks/smarttime": "^3.0.5",
|
"@pushrocks/smarttime": "^3.0.12",
|
||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"symbol-tree": "^3.2.2"
|
"symbol-tree": "^3.2.4"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/**/*",
|
||||||
"ts_web/*",
|
"ts_web/**/*",
|
||||||
"dist/*",
|
"dist/**/*",
|
||||||
"dist_web/*",
|
"dist_web/**/*",
|
||||||
"dist_ts_web/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
11
ts/lik.fastmap.ts
Normal file
11
ts/lik.fastmap.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as plugins from './lik.plugins';
|
||||||
|
|
||||||
|
export class FastMap<T> {
|
||||||
|
private mapObject: { [key: string]: T } = {};
|
||||||
|
|
||||||
|
public isUniqueKey() {}
|
||||||
|
|
||||||
|
public addToMap(identifier: string, objectArg: T) {
|
||||||
|
this.mapObject[identifier] = objectArg;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import * as plugins from './lik.plugins';
|
import * as plugins from './lik.plugins';
|
||||||
|
import { FastMap } from './lik.fastmap';
|
||||||
|
|
||||||
export interface IObjectmapForEachFunction<T> {
|
export interface IObjectmapForEachFunction<T> {
|
||||||
(itemArg: T): void;
|
(itemArg: T): void;
|
||||||
@ -12,8 +13,12 @@ export interface IObjectmapFindFunction<T> {
|
|||||||
* allows keeping track of objects
|
* allows keeping track of objects
|
||||||
*/
|
*/
|
||||||
export class Objectmap<T> {
|
export class Objectmap<T> {
|
||||||
|
private fastMap = new FastMap<T>();
|
||||||
private objectArray: T[] = [];
|
private objectArray: T[] = [];
|
||||||
|
|
||||||
|
// events
|
||||||
|
public eventSubject = new plugins.smartrx.rxjs.Subject<any>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a new instance
|
* returns a new instance
|
||||||
*/
|
*/
|
||||||
@ -21,6 +26,27 @@ export class Objectmap<T> {
|
|||||||
// nothing here
|
// 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
|
* add object to Objectmap
|
||||||
* returns false if the object is already in the map
|
* returns false if the object is already in the map
|
||||||
@ -33,6 +59,7 @@ export class Objectmap<T> {
|
|||||||
} else {
|
} else {
|
||||||
// the object is not yet in the objectmap
|
// the object is not yet in the objectmap
|
||||||
this.objectArray.push(objectArg);
|
this.objectArray.push(objectArg);
|
||||||
|
this.eventSubject.next('add');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +116,9 @@ export class Objectmap<T> {
|
|||||||
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
* gets an object in the Observablemap and removes it, so it can't be retrieved again
|
||||||
*/
|
*/
|
||||||
public getOneAndRemove(): T {
|
public getOneAndRemove(): T {
|
||||||
return this.objectArray.shift();
|
const removedItem = this.objectArray.shift();
|
||||||
|
this.eventSubject.next('remove');
|
||||||
|
return removedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,6 +154,7 @@ export class Objectmap<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.objectArray = replacementArray;
|
this.objectArray = replacementArray;
|
||||||
|
this.eventSubject.next('remove');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,5 +162,6 @@ export class Objectmap<T> {
|
|||||||
*/
|
*/
|
||||||
public wipe() {
|
public wipe() {
|
||||||
this.objectArray = [];
|
this.objectArray = [];
|
||||||
|
this.eventSubject.next('wiped');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ export class Stringmap {
|
|||||||
* like addString, but accepts an array of strings
|
* like addString, but accepts an array of strings
|
||||||
*/
|
*/
|
||||||
addStringArray(stringArrayArg: string[]) {
|
addStringArray(stringArrayArg: string[]) {
|
||||||
for (let stringItem of stringArrayArg) {
|
for (const stringItem of stringArrayArg) {
|
||||||
this.addString(stringItem);
|
this.addString(stringItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ export class Stringmap {
|
|||||||
* removes a string from Stringmap
|
* removes a string from Stringmap
|
||||||
*/
|
*/
|
||||||
removeString(stringArg: string) {
|
removeString(stringArg: string) {
|
||||||
for (let keyArg in this._stringArray) {
|
for (const keyArg in this._stringArray) {
|
||||||
if (this._stringArray[keyArg] === stringArg) {
|
if (this._stringArray[keyArg] === stringArg) {
|
||||||
this._stringArray.splice(parseInt(keyArg), 1);
|
this._stringArray.splice(parseInt(keyArg), 1);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ export class Stringmap {
|
|||||||
*/
|
*/
|
||||||
public checkMinimatch(miniMatchStringArg: string): boolean {
|
public checkMinimatch(miniMatchStringArg: string): boolean {
|
||||||
let foundMatch: boolean = false;
|
let foundMatch: boolean = false;
|
||||||
for (let stringItem of this._stringArray) {
|
for (const stringItem of this._stringArray) {
|
||||||
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
|
||||||
foundMatch = true;
|
foundMatch = true;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ export class Stringmap {
|
|||||||
*/
|
*/
|
||||||
public registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) {
|
public registerUntilTrue(functionArg: ITriggerFunction, doFunctionArg) {
|
||||||
this._triggerUntilTrueFunctionArray.push(() => {
|
this._triggerUntilTrueFunctionArray.push(() => {
|
||||||
let result = functionArg();
|
const result = functionArg();
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
doFunctionArg();
|
doFunctionArg();
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ export class Stringmap {
|
|||||||
* notifies triggers
|
* notifies triggers
|
||||||
*/
|
*/
|
||||||
private notifyTrigger() {
|
private notifyTrigger() {
|
||||||
let filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
const filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
||||||
return !functionArg();
|
return !functionArg();
|
||||||
});
|
});
|
||||||
this._triggerUntilTrueFunctionArray = filteredArray;
|
this._triggerUntilTrueFunctionArray = filteredArray;
|
||||||
|
Reference in New Issue
Block a user