mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add RecordObject.
This commit is contained in:
parent
eb6ba0374f
commit
147f3cf0c7
@ -190,6 +190,7 @@ export * from './util/AsyncHandler';
|
||||
export * from './util/HeaderUtil';
|
||||
export * from './util/PathUtil';
|
||||
export * from './util/QuadUtil';
|
||||
export * from './util/RecordObject';
|
||||
export * from './util/SequenceHandler';
|
||||
export * from './util/StreamUtil';
|
||||
export * from './util/WaterfallHandler';
|
||||
|
11
src/util/RecordObject.ts
Normal file
11
src/util/RecordObject.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Helper class for instantiating multiple objects with Components.js.
|
||||
* See https://github.com/LinkedSoftwareDependencies/Components.js/issues/26
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
||||
export class RecordObject implements Record<string, any> {
|
||||
public constructor(record: Record<string, string> = {}) {
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
return record;
|
||||
}
|
||||
}
|
12
test/unit/util/RecordObject.test.ts
Normal file
12
test/unit/util/RecordObject.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { RecordObject } from '../../../src/util/RecordObject';
|
||||
|
||||
describe('RecordObject', (): void => {
|
||||
it('returns an empty record when created without parameters.', async(): Promise<void> => {
|
||||
expect(new RecordObject()).toStrictEqual({});
|
||||
});
|
||||
|
||||
it('returns the passed record.', async(): Promise<void> => {
|
||||
const record = { abc: 'def' };
|
||||
expect(new RecordObject(record)).toBe(record);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user