yolodb 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Javi Aguilar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# YoloDB ๐
|
|
2
|
+
|
|
3
|
+
A lightweight, file-based JSON database powered by SuperJSON for Node.js (and compatible) runtimes. Perfect for
|
|
4
|
+
prototyping, testing, and when you just need a simple persistent store without the overhead of a full database system.
|
|
5
|
+
|
|
6
|
+
> Because setting up databases for local development is complex and You Only Live Once!
|
|
7
|
+
|
|
8
|
+
## Highlights โจ
|
|
9
|
+
|
|
10
|
+
- ๐ **Real-time file synchronization** - No stale data in multi-threaded/process environments (such as Next.js server)
|
|
11
|
+
- ๐ฏ **SuperJSON powered** - Support for Dates, Maps, Sets, and more complex data types
|
|
12
|
+
- ๐ ๏ธ **Developer friendly API** - Familiar CRUD operations with a simple, intuitive interface
|
|
13
|
+
- ๐ฆ **Zero configuration** - Just instantiate and start using
|
|
14
|
+
- ๐ **Type-safe** - Built with TypeScript for robust development
|
|
15
|
+
- ๐งช **Perfect for testing** - Mock your production database with ease
|
|
16
|
+
- ๐ **Debuggable** - Easily debug your data by checking the table files
|
|
17
|
+
|
|
18
|
+
## What's different compared to LowDB?
|
|
19
|
+
|
|
20
|
+
- Uses superjson for serialization/deserialization, so it supports more data types like Dates, Maps, Sets, etc.
|
|
21
|
+
- More intuitive interface, easier to use, closer to what would you expect from a real DB abstraction layer.
|
|
22
|
+
- Read/write operations are done on-the-fly. Less performant, but you don't need to worry about stale data.
|
|
23
|
+
- Comes with handy object-oriented abstractions such as `YoloDbRepository`
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
Install the package:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -D yolodb
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { yolodb } from 'yolodb'
|
|
35
|
+
|
|
36
|
+
// Create a table with a primary key
|
|
37
|
+
const usersTable = yolodb<User>('users.json', 'id', [])
|
|
38
|
+
|
|
39
|
+
// Insert a record
|
|
40
|
+
usersTable.insert({
|
|
41
|
+
id: '1',
|
|
42
|
+
name: 'John Doe',
|
|
43
|
+
createdAt: new Date(),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Find by ID
|
|
47
|
+
const user = usersTable.findById('1')
|
|
48
|
+
|
|
49
|
+
// Search with custom filter
|
|
50
|
+
const activeUsers = usersTable.search((user) => user.status === 'active')
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Why YoloDB? ๐ค
|
|
54
|
+
|
|
55
|
+
### Use Cases
|
|
56
|
+
|
|
57
|
+
- ๐งช **Testing and Development**
|
|
58
|
+
|
|
59
|
+
- Mock your production database (best way is via abstractions such as repository classes)
|
|
60
|
+
- Quick prototyping without database setup
|
|
61
|
+
- Isolated test environments
|
|
62
|
+
|
|
63
|
+
- ๐ฎ **Small Applications**
|
|
64
|
+
|
|
65
|
+
- Simple data persistence needs
|
|
66
|
+
- Prototypes and MVPs
|
|
67
|
+
- Local development tools
|
|
68
|
+
|
|
69
|
+
- ๐ **Learning Best Practices**
|
|
70
|
+
- A proof that you data model is well decoupled from the persistence layer, is that it can be mocked with ease
|
|
71
|
+
- Having living proof that your data model is well designed and you can switch between different persistence engines
|
|
72
|
+
with ease
|
|
73
|
+
|
|
74
|
+
### Advantages
|
|
75
|
+
|
|
76
|
+
- **Simple but Powerful**: Basic CRUD operations with a simple and familiar API
|
|
77
|
+
- **No Configuration**: Works out of the box
|
|
78
|
+
- **Type Safety**: Full TypeScript support
|
|
79
|
+
- **Complex Data Types**: Thanks to SuperJSON
|
|
80
|
+
- **Real-time File Access**: Always fresh data
|
|
81
|
+
- **Repository Pattern Support**: Clean architecture friendly
|
|
82
|
+
|
|
83
|
+
### Limitations
|
|
84
|
+
|
|
85
|
+
- **Not for Production**: Designed for development and testing
|
|
86
|
+
- **Performance costs**: Reads table files on every operation, and writes to disk on every write operation
|
|
87
|
+
- **Concurrency**: Basic file-based locking
|
|
88
|
+
- **Scale**: Not suitable for large datasets, since data is loaded into memory
|
|
89
|
+
|
|
90
|
+
## API Reference
|
|
91
|
+
|
|
92
|
+
### Table Operations
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const table = yolodb<Record>(filePath, primaryKeyField, initialData)
|
|
96
|
+
|
|
97
|
+
// Basic CRUD
|
|
98
|
+
table.all() // Get all records
|
|
99
|
+
table.findById(id) // Find by primary key
|
|
100
|
+
table.findBy(field, value) // Find by field value
|
|
101
|
+
table.search(filterFn) // Custom search
|
|
102
|
+
table.insert(record) // Insert single record
|
|
103
|
+
table.insertMany(records) // Bulk insert
|
|
104
|
+
table.update(record) // Update record
|
|
105
|
+
table.updateMany(records) // Bulk update
|
|
106
|
+
table.delete(id) // Delete by id
|
|
107
|
+
table.deleteMany(ids) // Bulk delete
|
|
108
|
+
table.truncate() // Clear all records
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Repository Pattern
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
interface UserRepository {
|
|
115
|
+
findByUsername(username: string): User | null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
class MockedUserRepository extends YoloDbRepository<User> implements UserRepository {
|
|
119
|
+
constructor() {
|
|
120
|
+
super("users.json", "id");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Implement interface methods here
|
|
124
|
+
}
|
|
125
|
+
// Your real repository would look like this:
|
|
126
|
+
class DrizzleUserRepository implements UserRepository { ... }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Best Practices ๐
|
|
130
|
+
|
|
131
|
+
1. **Use Type Definitions**
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
interface User {
|
|
135
|
+
id: string
|
|
136
|
+
name: string
|
|
137
|
+
createdAt: Date
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const usersTable = yolodb<User>('users.json', 'id', [])
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
2. **Implement Repository Pattern**
|
|
144
|
+
|
|
145
|
+
- Encapsulate database logic
|
|
146
|
+
- Add domain-specific methods
|
|
147
|
+
- Maintain clean architecture
|
|
148
|
+
|
|
149
|
+
3. **Handle Errors**
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
try {
|
|
153
|
+
table.insert(record)
|
|
154
|
+
} catch (error) {
|
|
155
|
+
// Handle file system errors
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
4. **Clean Up Data**
|
|
160
|
+
```typescript
|
|
161
|
+
// e.g. in your tests teardown
|
|
162
|
+
table.truncate()
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
Made with โค๏ธ for developers who know that sometimes, you just need a simple solution.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type YoloDbLogger = (...args: any[]) => void;
|
|
2
|
+
declare class YoloDbError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
type YoloDbTableOptions = {
|
|
6
|
+
logger?: YoloDbLogger;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Simple file-based JSON database built on top of SuperJSON.
|
|
10
|
+
*/
|
|
11
|
+
declare class YoloDbTable<R extends Record<string, any>> {
|
|
12
|
+
private readonly tableName;
|
|
13
|
+
private readonly pkField;
|
|
14
|
+
private readonly filePath;
|
|
15
|
+
private readonly options;
|
|
16
|
+
constructor(absoluteFilePath: string, pkField: keyof R, initialData?: R[], options?: YoloDbTableOptions);
|
|
17
|
+
private get log();
|
|
18
|
+
private getData;
|
|
19
|
+
all(): R[];
|
|
20
|
+
readFile(): R[];
|
|
21
|
+
saveFile(db: R[]): void;
|
|
22
|
+
findById(id: string): R | undefined;
|
|
23
|
+
findBy(field: keyof R, value: any): R[];
|
|
24
|
+
findFirstBy(field: keyof R, value: any): R | undefined;
|
|
25
|
+
search(filterFn: (record: R) => boolean): R[];
|
|
26
|
+
insert(record: R): void;
|
|
27
|
+
insertMany(records: R[]): void;
|
|
28
|
+
update(record: Partial<R>): void;
|
|
29
|
+
updateMany(records: Array<Partial<R>>): void;
|
|
30
|
+
delete(id: string): void;
|
|
31
|
+
deleteMany(ids: string[]): void;
|
|
32
|
+
truncate(): void;
|
|
33
|
+
}
|
|
34
|
+
declare class YoloDbRepository<R extends Record<string, any>> {
|
|
35
|
+
protected table: YoloDbTable<R>;
|
|
36
|
+
constructor(dataPath: string, pkField: keyof R);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to create a new YoloDB table.
|
|
40
|
+
* It reuses the same table instance if the same file path is used.
|
|
41
|
+
*/
|
|
42
|
+
declare function yolodb<R extends Record<string, any>>(filePath: string, pkField: keyof R, initialData: R[], options?: YoloDbTableOptions): YoloDbTable<R>;
|
|
43
|
+
|
|
44
|
+
export { YoloDbError, type YoloDbLogger, YoloDbRepository, YoloDbTable, type YoloDbTableOptions, yolodb };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/yolodb.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import superjson from "superjson";
|
|
5
|
+
var YoloDbError = class extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`[YoloDB] ${message}`);
|
|
8
|
+
this.name = "YoloDbError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var YoloDbTable = class {
|
|
12
|
+
constructor(absoluteFilePath, pkField, initialData = [], options) {
|
|
13
|
+
const dirName = path.dirname(absoluteFilePath);
|
|
14
|
+
if (!fs.existsSync(dirName)) {
|
|
15
|
+
fs.mkdirSync(dirName, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
this.tableName = path.basename(absoluteFilePath).replace(".json", "");
|
|
18
|
+
this.pkField = pkField;
|
|
19
|
+
this.filePath = absoluteFilePath;
|
|
20
|
+
this.options = {
|
|
21
|
+
logger: (...args) => console.debug(`[YoloDB] ${this.tableName}`, ...args),
|
|
22
|
+
...options
|
|
23
|
+
};
|
|
24
|
+
if (!fs.existsSync(absoluteFilePath)) {
|
|
25
|
+
this.saveFile(initialData);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
get log() {
|
|
29
|
+
return this.options.logger;
|
|
30
|
+
}
|
|
31
|
+
getData() {
|
|
32
|
+
const db = this.readFile();
|
|
33
|
+
if (!Array.isArray(db)) {
|
|
34
|
+
throw new YoloDbError(`Invalid data in ${this.filePath}`);
|
|
35
|
+
}
|
|
36
|
+
return db;
|
|
37
|
+
}
|
|
38
|
+
all() {
|
|
39
|
+
return this.getData();
|
|
40
|
+
}
|
|
41
|
+
readFile() {
|
|
42
|
+
this.log(`Reading table from ${this.filePath}`);
|
|
43
|
+
if (!fs.existsSync(this.filePath)) {
|
|
44
|
+
this.saveFile([]);
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const fileContent = fs.readFileSync(this.filePath, "utf8");
|
|
48
|
+
return superjson.parse(fileContent);
|
|
49
|
+
}
|
|
50
|
+
saveFile(db) {
|
|
51
|
+
this.log(`Saving table to ${this.filePath}`);
|
|
52
|
+
fs.writeFileSync(this.filePath, JSON.stringify(superjson.serialize(db), null, 2));
|
|
53
|
+
}
|
|
54
|
+
findById(id) {
|
|
55
|
+
const db = this.getData();
|
|
56
|
+
return db.find((record) => record[this.pkField] === id);
|
|
57
|
+
}
|
|
58
|
+
findBy(field, value) {
|
|
59
|
+
const db = this.getData();
|
|
60
|
+
return db.filter((record) => record[field] === value);
|
|
61
|
+
}
|
|
62
|
+
findFirstBy(field, value) {
|
|
63
|
+
const db = this.getData();
|
|
64
|
+
return db.find((record) => record[field] === value);
|
|
65
|
+
}
|
|
66
|
+
search(filterFn) {
|
|
67
|
+
const db = this.getData();
|
|
68
|
+
return db.filter((record) => filterFn(record));
|
|
69
|
+
}
|
|
70
|
+
insert(record) {
|
|
71
|
+
const pk = record[this.pkField];
|
|
72
|
+
if (!pk) {
|
|
73
|
+
throw new YoloDbError(`Record does not have a primary key: ${this.tableName}.${String(this.pkField)}`);
|
|
74
|
+
}
|
|
75
|
+
const db = this.getData();
|
|
76
|
+
db.push(record);
|
|
77
|
+
this.saveFile(db);
|
|
78
|
+
}
|
|
79
|
+
insertMany(records) {
|
|
80
|
+
const db = this.getData();
|
|
81
|
+
db.push(...records);
|
|
82
|
+
this.saveFile(db);
|
|
83
|
+
}
|
|
84
|
+
update(record) {
|
|
85
|
+
const pk = record[this.pkField];
|
|
86
|
+
if (!pk) {
|
|
87
|
+
throw new YoloDbError(`Record not found in ${this.tableName}: ${pk}`);
|
|
88
|
+
}
|
|
89
|
+
const db = this.getData();
|
|
90
|
+
for (const currentRecord of db) {
|
|
91
|
+
if (currentRecord[this.pkField] === pk) {
|
|
92
|
+
Object.assign(currentRecord, record);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.saveFile(db);
|
|
97
|
+
}
|
|
98
|
+
updateMany(records) {
|
|
99
|
+
records.forEach((record) => this.update(record));
|
|
100
|
+
}
|
|
101
|
+
delete(id) {
|
|
102
|
+
this.deleteMany([id]);
|
|
103
|
+
}
|
|
104
|
+
deleteMany(ids) {
|
|
105
|
+
this.log(`Deleting ${ids.length} records`);
|
|
106
|
+
const db = this.getData().filter((record) => !ids.includes(record[this.pkField]));
|
|
107
|
+
this.saveFile(db);
|
|
108
|
+
}
|
|
109
|
+
truncate() {
|
|
110
|
+
this.saveFile([]);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var YoloDbRepository = class {
|
|
114
|
+
constructor(dataPath, pkField) {
|
|
115
|
+
this.table = yolodb(dataPath, pkField, []);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var _yoloDbTables = {};
|
|
119
|
+
function yolodb(filePath, pkField, initialData, options) {
|
|
120
|
+
if (!_yoloDbTables[filePath]) {
|
|
121
|
+
_yoloDbTables[filePath] = new YoloDbTable(filePath, pkField, initialData, options);
|
|
122
|
+
}
|
|
123
|
+
return _yoloDbTables[filePath];
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
YoloDbError,
|
|
127
|
+
YoloDbRepository,
|
|
128
|
+
YoloDbTable,
|
|
129
|
+
yolodb
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/yolodb.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport superjson from 'superjson'\n\nexport type YoloDbLogger = (...args: any[]) => void\n\nexport class YoloDbError extends Error {\n constructor(message: string) {\n super(`[YoloDB] ${message}`)\n this.name = 'YoloDbError'\n }\n}\n\nexport type YoloDbTableOptions = {\n logger?: YoloDbLogger\n}\n\n/**\n * Simple file-based JSON database built on top of SuperJSON.\n */\nexport class YoloDbTable<R extends Record<string, any>> {\n private readonly tableName: string\n private readonly pkField: keyof R\n private readonly filePath: string\n private readonly options: Required<YoloDbTableOptions>\n\n constructor(absoluteFilePath: string, pkField: keyof R, initialData: R[] = [], options?: YoloDbTableOptions) {\n const dirName = path.dirname(absoluteFilePath)\n\n if (!fs.existsSync(dirName)) {\n fs.mkdirSync(dirName, { recursive: true })\n }\n\n this.tableName = path.basename(absoluteFilePath).replace('.json', '')\n this.pkField = pkField\n this.filePath = absoluteFilePath\n\n this.options = {\n logger: (...args) => console.debug(`[YoloDB] ${this.tableName}`, ...args),\n ...options,\n }\n\n if (!fs.existsSync(absoluteFilePath)) {\n this.saveFile(initialData)\n }\n }\n\n private get log(): YoloDbLogger {\n return this.options.logger\n }\n\n private getData(): R[] {\n const db = this.readFile()\n if (!Array.isArray(db)) {\n throw new YoloDbError(`Invalid data in ${this.filePath}`)\n }\n return db\n }\n\n all(): R[] {\n return this.getData()\n }\n\n readFile(): R[] {\n this.log(`Reading table from ${this.filePath}`)\n\n if (!fs.existsSync(this.filePath)) {\n this.saveFile([])\n return []\n }\n\n const fileContent = fs.readFileSync(this.filePath, 'utf8')\n return superjson.parse<R[]>(fileContent)\n }\n\n saveFile(db: R[]): void {\n this.log(`Saving table to ${this.filePath}`)\n fs.writeFileSync(this.filePath, JSON.stringify(superjson.serialize(db), null, 2))\n }\n\n findById(id: string): R | undefined {\n const db = this.getData()\n return db.find((record) => record[this.pkField] === id)\n }\n\n findBy(field: keyof R, value: any): R[] {\n const db = this.getData()\n return db.filter((record) => record[field] === value)\n }\n\n findFirstBy(field: keyof R, value: any): R | undefined {\n const db = this.getData()\n return db.find((record) => record[field] === value)\n }\n\n search(filterFn: (record: R) => boolean): R[] {\n const db = this.getData()\n return db.filter((record) => filterFn(record))\n }\n\n insert(record: R): void {\n const pk = record[this.pkField]\n if (!pk) {\n throw new YoloDbError(`Record does not have a primary key: ${this.tableName}.${String(this.pkField)}`)\n }\n\n const db = this.getData()\n db.push(record)\n\n this.saveFile(db)\n }\n\n insertMany(records: R[]): void {\n const db = this.getData()\n db.push(...records)\n\n this.saveFile(db)\n }\n\n update(record: Partial<R>): void {\n const pk = record[this.pkField]\n if (!pk) {\n throw new YoloDbError(`Record not found in ${this.tableName}: ${pk}`)\n }\n\n const db = this.getData()\n\n for (const currentRecord of db) {\n if (currentRecord[this.pkField] === pk) {\n Object.assign(currentRecord, record)\n break\n }\n }\n\n this.saveFile(db)\n }\n\n updateMany(records: Array<Partial<R>>): void {\n records.forEach((record) => this.update(record))\n }\n\n delete(id: string): void {\n this.deleteMany([id])\n }\n\n deleteMany(ids: string[]): void {\n this.log(`Deleting ${ids.length} records`)\n const db = this.getData().filter((record) => !ids.includes(record[this.pkField]))\n\n this.saveFile(db)\n }\n\n truncate(): void {\n this.saveFile([])\n }\n}\n\nexport class YoloDbRepository<R extends Record<string, any>> {\n protected table: YoloDbTable<R>\n\n constructor(dataPath: string, pkField: keyof R) {\n this.table = yolodb<R>(dataPath, pkField, [])\n }\n}\n\n// In-memory cache of YoloDB table instances\nconst _yoloDbTables: Record<string, YoloDbTable<any>> = {}\n\n/**\n * Helper function to create a new YoloDB table.\n * It reuses the same table instance if the same file path is used.\n */\nexport function yolodb<R extends Record<string, any>>(\n filePath: string,\n pkField: keyof R,\n initialData: R[],\n options?: YoloDbTableOptions,\n): YoloDbTable<R>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
|
2
|
+
"name": "yolodb",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"homepage": "https://itsjavi.com/yolodb",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/itsjavi/yolodb.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup src/index.ts --dts --sourcemap --format esm --clean",
|
|
27
|
+
"format": "sort-package-json && prettier --write ./src README.md tsconfig.json",
|
|
28
|
+
"lint": "pnpm run typecheck && prettier --check ./src README.md tsconfig.json && publint",
|
|
29
|
+
"prepare": "sort-package-json",
|
|
30
|
+
"prepublishOnly": "pnpm run lint && pnpm run build",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"superjson": "^2.2.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^22.13.4",
|
|
38
|
+
"prettier": "^3.5.1",
|
|
39
|
+
"publint": "^0.3.5",
|
|
40
|
+
"sort-package-json": "^2.14.0",
|
|
41
|
+
"tsup": "^8.3.6",
|
|
42
|
+
"typescript": "^5.7.3"
|
|
43
|
+
},
|
|
44
|
+
"pnpm": {
|
|
45
|
+
"onlyBuiltDependencies": [
|
|
46
|
+
"esbuild"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|