15 Commits

Author SHA1 Message Date
9eec43044d 1.0.11 2018-12-02 15:39:52 +01:00
4df1274094 fix(core): update 2018-12-02 15:39:52 +01:00
1edda548a1 1.0.10 2018-12-02 15:34:05 +01:00
c94b5e0009 fix(tests): update 2018-12-02 15:34:05 +01:00
fd5f5e357c 1.0.9 2018-09-08 01:11:25 +02:00
57f50ef507 fix(core): update 2018-09-08 01:11:25 +02:00
58bcf0cea2 1.0.8 2018-08-22 00:35:03 +02:00
bf2d3f661e fix(remove obsolete console logs): update 2018-08-22 00:35:03 +02:00
eef3fd7c1f 1.0.7 2018-08-19 21:25:21 +02:00
219944218c fix(CI): remove obsolete build dependencies 2018-08-19 21:25:21 +02:00
00364d261a 1.0.6 2018-08-19 21:19:23 +02:00
04aa6b2fb5 fix(dependencies): update 2018-08-19 21:19:23 +02:00
e113ce5e8e 1.0.5 2018-07-13 22:23:40 +02:00
3e2086fe34 fix(package): name 2018-07-13 22:23:40 +02:00
f9e7204294 1.0.4 2018-07-13 22:20:09 +02:00
8 changed files with 568 additions and 333 deletions

View File

@@ -26,6 +26,7 @@ mirror:
snyk: snyk:
stage: security stage: security
script: script:
- npmci npm prepare
- npmci command npm install -g snyk - 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
@@ -36,21 +37,11 @@ snyk:
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS: testLTS:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install lts - npmci node install lts
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
@@ -62,6 +53,7 @@ testLTS:
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
@@ -117,8 +109,10 @@ pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g npmpage - npmci command npm install -g typedoc typescript
- npmci command npmpage - npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags: tags:
- docker - docker
- notpriv - notpriv
@@ -129,13 +123,3 @@ pages:
paths: paths:
- public - public
allow_failure: true allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@@ -1,9 +1,6 @@
{ {
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
"@gitzone/npmts",
"ts-node"
],
"npmAccessLevel": "public" "npmAccessLevel": "public"
} }
} }

792
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "smartcache", "name": "@pushrocks/smartcache",
"version": "1.0.3", "version": "1.0.11",
"private": false, "private": false,
"description": "cache things in smart ways", "description": "cache things in smart ways",
"main": "dist/index.js", "main": "dist/index.js",
@@ -8,19 +8,23 @@
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tsrun test/test.ts)", "test": "(tstest test/)",
"build": "(npmts)" "build": "(tsbuild)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsrun": "^1.1.2", "@gitzone/tsbuild": "^2.0.22",
"@types/node": "^10.5.2", "@gitzone/tsrun": "^1.1.13",
"tapbundle": "^2.0.2" "@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.11",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.17.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.1", "@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smarterror": "^2.0.1", "@pushrocks/smarterror": "^2.0.1",
"@pushrocks/smarthash": "^2.0.0",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smarttime": "^2.0.1", "@pushrocks/smarttime": "^3.0.5"
"nodehash": "^1.0.4"
} }
} }

View File

@@ -1,38 +1,38 @@
import { expect, tap } from "tapbundle"; import { expect, tap } from '@pushrocks/tapbundle';
import * as smartcache from "../ts/index"; import * as smartcache from '../ts/index';
import * as smartdelay from "@pushrocks/smartdelay"; import * as smartdelay from '@pushrocks/smartdelay';
let smartcacheInstance: smartcache.SmartCache; let smartcacheInstance: smartcache.SmartCache;
tap.test("should create a valid instance of SmartCache", async () => { tap.test('should create a valid instance of SmartCache', async () => {
smartcacheInstance = new smartcache.SmartCache(); smartcacheInstance = new smartcache.SmartCache();
expect(smartcacheInstance).to.be.instanceof(smartcache.SmartCache); expect(smartcacheInstance).to.be.instanceof(smartcache.SmartCache);
}); });
tap.test("try to get async responses", async () => { tap.test('try to get async responses', async () => {
const getResponse = async () => { const getResponse = async () => {
const response = await smartcacheInstance const response = await smartcacheInstance
.cacheReturn(async () => { .cacheReturn(async () => {
console.log("function ran"); console.log('function ran');
return "hello"; return 'hello';
}, 1000) }, 1000)
.catch(err => { .catch(err => {
console.log(err); console.log(err);
}); });
console.log("response is:"); console.log('response is:');
console.log(response); console.log(response);
}; };
const getResponse2 = async () => { const getResponse2 = async () => {
const response = await smartcacheInstance const response = await smartcacheInstance
.cacheReturn(async () => { .cacheReturn(async () => {
console.log("function 2 ran"); console.log('function 2 ran');
return "hello"; return 'hello';
}, 1000) }, 1000)
.catch(err => { .catch(err => {
console.log(err); console.log(err);
}); });
console.log("response is:"); console.log('response is:');
console.log(response); console.log(response);
}; };
@@ -40,8 +40,8 @@ tap.test("try to get async responses", async () => {
getResponse(); getResponse();
getResponse2(); getResponse2();
getResponse2(); getResponse2();
smartdelay.delayFor(1000).then(() => { await smartdelay.delayFor(1000).then(async () => {
getResponse(); await getResponse();
// getResponse2(); // getResponse2();
}); });
}); });

View File

@@ -6,9 +6,9 @@ export class SmartCache {
async cacheReturn(asyncCachedFuncArg: () => Promise<any>, cacheDuration: number = 5000) { async cacheReturn(asyncCachedFuncArg: () => Promise<any>, cacheDuration: number = 5000) {
let callStack: string = new plugins.smarterror.SmartError('').cleanFullStack; let callStack: string = new plugins.smarterror.SmartError('').cleanFullStack;
let callHash = plugins.nodehash.sha256FromStringSync(callStack); let callHash = plugins.smarthash.sha256FromStringSync(callStack);
console.log(callHash); // console.log(callHash);
if ( if (
this._cacheManager.cacheExists(callHash) && this._cacheManager.cacheExists(callHash) &&
(await this._cacheManager.waitForCacheReady(callHash)) && (await this._cacheManager.waitForCacheReady(callHash)) &&

View File

@@ -2,6 +2,6 @@ import * as smartdelay from '@pushrocks/smartdelay';
import * as smarterror from '@pushrocks/smarterror'; import * as smarterror from '@pushrocks/smarterror';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smarttime from '@pushrocks/smarttime'; import * as smarttime from '@pushrocks/smarttime';
import * as nodehash from 'nodehash'; import * as smarthash from '@pushrocks/smarthash';
export { smarterror, smartdelay, smartpromise, smarttime, nodehash }; export { smarterror, smartdelay, smartpromise, smarttime, smarthash };

View File

@@ -1,3 +1,17 @@
{ {
"extends": "tslint-config-standard" "extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
} }