Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- node/install-packages:
pkg-manager: npm
- run:
command: npm run test
command: npm run test:raw
name: Run tests
- persist_to_workspace:
root: ~/project
Expand Down
11 changes: 8 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ scripts
.circleci
.git

# Config
nodemon.json
tsconfig.json
jest.config.js
.eslintrc.json
.prettierrc

# Files
**.tsbuildinfo
tsconfig.json
package-lock.json
yarn.lock
bun.lockb
jest.config.js
.eslintrc.json
.gitignore
CHANGELOG.md
DEV.md

# backup created by custom publish script
package-backup.json
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"printWidth": 140,
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf",
"useTabs": false,
"editorconfig": false
}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- **How easy is scalable multithreading with Nanolith?** portion to README.
- Refresh functionality for `test` and `play` scripts.
- **.prettierrc** file.
- **DEV.md** file for contributors.
- Type exports for `Service`, `ReadableFromPort`, and `WritableFromPort`.

### Fixed

- `SharedMap.entries()` not using mutex.
- Improved performance for `build` script.
- Uncaught exceptions in `__initializeService` not able to be handled by `exceptionHandler()` in `Service`s (temporary solution without proper `terminate()` functionality).

### Removed

- `build:clean` and `test:clean` scripts.
- Deprecated `SharedMapWatch` type.

## [0.4.6] - 2023-30-4

### Changed
Expand Down
65 changes: 65 additions & 0 deletions DEV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Hello, developer! Welcome to ✨Nanolith✨

This is a short guide on how to navigate the repository and contribute to the project.

## Process

The **main** branch is always the `@latest` release, and the `@next` release lives on a branch named after its version (**v.X.X.X**).

1. [Pick an issue](https://github.com/mstephen19/nanolith/issues) you'd like to address, or [create your own issue](https://github.com/mstephen19/nanolith/issues/new/choose)!
2. Pull down the repository and checkout to the **next** version's branch.
3. Checkout your branch, and give it a descriptive name (ex. **add-launchservice-build-args**).
4. Make your changes, ensuring to commit along the way (following the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard).
5. Write **tests**. We're serious about testing, so write a few unit/integration tests!
6. Add your changes to the **CHANGELOG.md** file.
7. Throw up a PR and request a review from **[mstephen19](https://github.com/mstephen19)**.
8. Receive feedback and get approved!

## Some things to help you

Developer experience is what Nanolith is all about, and that doesn't just include the developers using the library!

### We've got CI

For every commit on your branch for which a PR is open, the build and test scripts will run automatically (using CircleCI). So hey, open that PR up early on and you'll see a cute little green checkmark next to your commits letting you know that you're all good.

### Prettier configuration

If your editor of choice is [VSCode](https://code.visualstudio.com/download), you can automatically format your code contributions to the project's standards by installing the [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extension and enabling **Format on Save**.

### Playground

Alongside the **\_\_test\_\_** folder sits a **\_\_playground\_\_** folder. This is a place where you can manually test things out, log things, or just play around with the library. Note that when having your PR reviewed, the contents of this folder doesn't really matter (within reason). Use the [`play`](#play) script to automatically run your code within the **\_\_playground\_\_** folder any time a file within **src** changes.

> **Why this folder?** In the beginning of Nanolith's development, I (Matt) was using `npm link` to install the package locally into a separate "test" project. This became cumbersome, as for every change the project needed to be re-linked and re-installed in the "test" project.

### Scripts

While contributing to the project, you'll find these three scripts to be quite useful.

#### `build`

This command will lint, compile, and minify the code. This is the script that is used to build the project for production.

#### `test`

Run tests in watch mode! This means that whenever you update a file, the tests will be run again!

You might not want to run all the tests every time though, as that does take a little bit of time. To just run certain tests, include a matcher string for the name of the suite:

```sh
# only run test suites including "service" in their name
npm run test service
```

> **Tip:** A shortcut for `npm run test` is `npm t`.

#### `play`

Automatically run your code within the [**\_\_playground\_\_** folder](#playground) any time a file within **src** changes.

## Conclusion

Thanks a ton for your interest in contributing to Nanolith, and for keeping the open-source community a healthy environment for everyone!

If you've got any questions about the project, feel free to email **[mstephen19](https://github.com/mstephen19)**.
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,41 @@
There have always been a few main goals for Nanolith:

1. Performance & scalability 🏃
2. Ease-of-use 😇
2. Ease-of-use with great in-editor docs 😇
3. Seamless TypeScript support 😎
4. Modern [ESModules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) support 📈
5. Steady updates with new features & fixes 🚀
4. Tested and battle-ready. Always 🧪
5. Modern [ESModules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) support 📈
6. Steady updates with new features & fixes 🚀

### How easy is scalable multithreading with Nanolith?

This easy:

```TypeScript
// worker.ts
import { define } from 'nanolith';

export const worker = await define({
yourTask() {},
});

// index.ts
import { pool } from 'nanolith';
import { worker } from './worker.js';

// Spawn multiple concurrent threads
const cluster = await worker.clusterize(pool.maxConcurrency, {
autoRenew: true,
exceptionHandler({ error, terminate }) {
//
}
});

// Run your task on one of the threads
await cluster.use().call({ name: 'yourTask' });
```

Nanolith cuts out the need to manually manage concurrency. Additionally, handling errors, managing nested threads, message-passing, and more are all intuitive.

### So what can you do with it?

Expand Down
4 changes: 4 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"watch": "./src",
"ext": "ts"
}
Loading