Skip to content

Commit

Permalink
feat: create collection implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSebastianDev committed Nov 20, 2022
1 parent e07a4b4 commit 60a857e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/** @format */

export { Flotsam } from './lib';
export type { Collection, ObjectId } from './lib';
export type { FlotsamInit, FlotsamEvent, Subscriber, Unsubscriber } from './types';
30 changes: 30 additions & 0 deletions src/lib/Collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @format */

import { __root } from '../utils';
import fs from 'node:fs';

export class Collection<T extends Record<string, unknown>> {
#dir: string;
constructor(private namespace: string) {
this.#dir = __root(this.namespace);

process.on('SIGINT', async () => {
await this.serialize();
});

process.on('SIGTERM', async () => {
await this.serialize();
});
}

get count() {
return 0;
}

get entries() {
return [];
}

async deserialize() {}
async serialize() {}
}
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @format */

export { Flotsam } from './Flotsam';
export { Collection } from './Collection';
export { ObjectId } from './ObjectId';

0 comments on commit 60a857e

Please sign in to comment.