Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@karacas/kaysh
Advanced tools
In-memory caching with support for RxJs observables, native promises, functions & methods. Optional localStorage.
const optional_config = {
localStorage: true /* Uses localStorage / Promises and RxJs automatically save a resolved value | dafault:false */,
maxItems: 10 /* Maximum values cached per function/args | dafault:10 */,
maxTime: 5 * 1000 /* Maximum time of the cached value in milliseconds | dafault:0(infinite) */,
};
import { kayshOperator, kayshFlushOperator } from '@karacas/kaysh';
const getObservable = (payLoad?) => {
return of(Math.random() + JSON.stringify(payLoad))
.pipe(kayshOperator('getObservable', payLoad, optional_config));
};
const flushObservableValue = (payLoad?) => kayshFlushOperator('getObservable', payLoad);
const flushObservable = () => kayshFlushOperator('getObservable');
Expects
test('TestObserbable Operator', async function() {
let value1 = await getObservable([1, 2]).toPromise();
let value2 = await getObservable([1, 2]).toPromise();
expect(value1).toBe(value2);
flushObservableValue([1, 2]); // or flushObservable() for all values
let value3 = await getObservable([1, 2]).toPromise();
expect(value3).not.toBe(value1);
});
function testFunction(val) {
return String(Math.random()) + JSON.stringify(val);
}
const testFunctionMem = kayshMemFunction(testFunction, optional_config);
const flush = kayshFlushMemFunction(testFunction);
Expects
test('Test Simple function', function() {
let value1 = testFunctionMem({ test: [1] });
let value2 = testFunctionMem({ test: [1] });
expect(value1).toBe(value2);
flush({ test: [1] }); // or flush() for all values
let value3 = testFunctionMem({ test: [1] });
expect(value3).not.toBe(value1);
});
import { kayshMemFunction, kayshFlushMemFunction, kayshDecorator } from '@karacas/kaysh';
class CacheTestClass {
//Normal
funcTest(v = 100) {
return 1 + v;
}
funcTestMemo = kayshMemFunction(this.funcTest);
flushFuncTestMemo = kayshFlushMemFunction(this.funcTest);
}
Or
class CacheClassExampleWithDecorator {
//Decorator
@kayshDecorator(kayshOptions)
testDecorated(v = 100) {
return 1 + v;
}
flushTestDecorated = kayshFlushMemFunction(this.testDecorated);
}
FAQs
In-memory caching with support for RxJs observables, native promises, functions & methods. Optional localStorage.
We found that @karacas/kaysh demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.