# @cosby/native-basic-math

> This project is an example of a Native Node.js module implemented in C++ with TypeScript/JavaScript bindings. It provides basic arithmetic operations such as addition and subtraction, serving as a foundation for learning or building more complex native mo

Latest version **1.0.3** (published 2024-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cosby/native-basic-math
pnpm add @cosby/native-basic-math
yarn add @cosby/native-basic-math
bun add @cosby/native-basic-math
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2024-08-15 |
| First published | 2024-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 61.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 0 |
| Author | Cosby |
| Maintainers | cosby |
| Keywords | node-addon, native-module, math, C++, typescript |

## Links

- npm: https://www.npmjs.com/package/@cosby/native-basic-math
- Repository: https://github.com/Cosby1992/ts-cpp-module-example
- Issues: https://github.com/Cosby1992/ts-cpp-module-example/issues
- npm.io page: https://npm.io/package/@cosby/native-basic-math

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2024-08-15
- 1.0.2 — 2024-08-15
- 1.0.1 — 2024-08-15
- 1.0.0 — 2024-08-15

## README

# Native Basic Math

This project is an example of a Native Node.js module implemented in C++ with TypeScript/JavaScript bindings. It provides basic arithmetic operations such as addition and subtraction, serving as a foundation for learning or building more complex native modules.


## Installation
### Using NPM
```bash
npm install @cosby/native-basic-math
```

### Using Yarn
```bash
yarn add @cosby/native-basic-math
```

### Using PNPM
```
pnpm i @cosby/native-basic-math
```

## Usage

```js
const math = require('@cosby/native-basic-math');

// Addition
console.log(math.sum(2, 3)); // Output: 5

// Subtraction
console.log(math.sub(5, 2)); // Output: 3

// Multiplication
console.log(math.mul(3, 4)); // Output: 12

// Division
console.log(math.div(10, 2)); // Output: 5

```

or

```ts
import math from '@cosby/native-basic-math';

// Addition
console.log(math.sum(2, 3)); // Output: 5

// Subtraction
console.log(math.sub(5, 2)); // Output: 3

// Multiplication
console.log(math.mul(3, 4)); // Output: 12

// Division
console.log(math.div(10, 2)); // Output: 5

```

## API
| Function                              | Description                                                           |
|----------------------------------------|----------------------------------------------------------------------|
| `sum(a: number, b: number): number`   | Returns the sum of `a` and `b`.                                       |
| `sub(a: number, b: number): number`   | Returns the difference when `b` is subtracted from `a`.               |
| `mul(a: number, b: number): number`   | *Not yet implemented.* Intended to return the product of `a` and `b`. |
| `div(a: number, b: number): number`   | *Not yet implemented.* Intended to return the quotient when `a` is divided by `b`. Throws an error if `b` is 0. |



## Building the module
If you want to build the module from source, run:
```bash
yarn build
```
This will clean the environment, build the C++ native module, and compile TypeScript files.

## License
This project is licensed under the MIT License. See the [LICENSE](./LICENCE) file for details.

---
_Source: https://npm.io/package/@cosby/native-basic-math · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
