Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
craigdallimore committed Mar 31, 2022
0 parents commit 5e867a3
Show file tree
Hide file tree
Showing 13 changed files with 3,045 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
env: {
node: true,
browser: true,
es2021: true,
},
root: true,
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
plugins: ["@typescript-eslint"],
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
rules: {
"typescript-eslint:triple-slash-reference": "off",
"eol-last": 2,
},
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
static/bundle.js
lib
Empty file added .npmignore
Empty file.
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Craig Dallimore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Vector 2D

[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

```
npm install @decoy9697/vector
```

This library defines a `Vector` as a tuple with 2 floats: `[number, number]`

It exposes the following functions for working with these vectors:

| Name | Type |
| --------------- | ---------------------------- |
| add | `(Vector, Vector) => Vector` |
| cross | `(Vector, Vector) => number` |
| degreesToVector | `(number) => Vector` |
| distance | `(Vector, Vector) => number` |
| dot | `(Vector, Vector) => number` |
| length | `(Vector) => number` |
| multiply | `(Vector, number) => Vector` |
| normalise | `(Vector) => Vector` |
| radiansToVector | `(number) => Vector` |
| subtract | `(Vector, Vector) => Vector` |
| vectorToRadians | `(Vector) => number` |

<!-- Definitions -->

[downloads-badge]: https://img.shields.io/npm/dm/@decoy9697/vector.svg
[downloads]: https://www.npmjs.com/package/@decoy9697/vector
[size-badge]: https://img.shields.io/bundlephobia/minzip/@decoy9697/vector.svg
[size]: https://bundlephobia.com/result?p=@decoy9697/vector
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
/* eslint @typescript-eslint/no-var-requires: "off" */

module.exports = {
rootDir: "src",
preset: "ts-jest",
testEnvironment: "jest-environment-jsdom",
};
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "vector",
"version": "1.0.0",
"description": "A 2d vector library",
"repository": "https://github.com/craigdallimore/vector",
"bugs": {
"url": "https://github.com/craigdallimore/issues",
"email": "decoy9697@gmail.com"
},
"keywords": [
"vector",
"math",
"2d"
],
"files": [
"dist"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "craigdallimore <decoy9697@gmail.com>",
"license": "MIT",
"private": false,
"scripts": {
"test": "jest"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"fast-check": "^2.24.0",
"jest": "^27.5.1"
},
"dependencies": {
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
}
}
17 changes: 17 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-21.11.tar.gz") {};
in pkgs.stdenv.mkDerivation {
name = "priorirty-queue";
buildInputs = [
pkgs.yarn #coc.vim
pkgs.nodejs-14_x #coc.vim
];
shellHook = ''
alias gst='git status'
alias gd='git diff'
alias gc='git commit'
:q() {
exit
}
'';
}
Loading

0 comments on commit 5e867a3

Please sign in to comment.