diff --git a/src/nanomath.js b/src/nanomath.js new file mode 100644 index 0000000..662e1ba --- /dev/null +++ b/src/nanomath.js @@ -0,0 +1,7 @@ +import {numbers} from './numbers.js' + +for (const key in numbers) { + for (const subkey in numbers[key]) { + console.log(`${key}.${subkey} =`, numbers[key][subkey]) + } +} diff --git a/src/number/Number.js b/src/number/Number.js new file mode 100644 index 0000000..93f5837 --- /dev/null +++ b/src/number/Number.js @@ -0,0 +1,3 @@ +export const Number = { + test: n => typeof n === 'number' +} diff --git a/src/number/all.js b/src/number/all.js new file mode 100644 index 0000000..d82eb49 --- /dev/null +++ b/src/number/all.js @@ -0,0 +1,4 @@ +export * as typeDefinition from './Number.js' +export * as arithmetic from './arithmetic.js' +export * as type from './type.js' +export * as utils from './utils.js' diff --git a/src/number/arithmetic.js b/src/number/arithmetic.js index e206736..ebb26b7 100644 --- a/src/number/arithmetic.js +++ b/src/number/arithmetic.js @@ -1,4 +1,4 @@ -import {number, plain} from './type' +import {plain} from './tools.js' export const abs = plain(Math.abs) export const absquare = plain(a => a*a) diff --git a/src/number/tools.js b/src/number/tools.js new file mode 100644 index 0000000..da9fe1e --- /dev/null +++ b/src/number/tools.js @@ -0,0 +1,4 @@ +import {Number} from "./Number.js" + +export const plain = f => + [Array(f.length).fill(Number), {returns: Number, behavior: f}] diff --git a/src/number/type.js b/src/number/type.js index ece6060..eb241fe 100644 --- a/src/number/type.js +++ b/src/number/type.js @@ -1,6 +1,4 @@ -export const number = { - test: n => typeof n === 'number' -} +import {plain} from './tools.js' -export plain = f => - [Array(f.length).fill(number), {returns: number, behavior: f}] +// Not much to do so far when there is only one type +export const number = plain(a => a) diff --git a/src/number/utils.js b/src/number/utils.js new file mode 100644 index 0000000..d6b18bb --- /dev/null +++ b/src/number/utils.js @@ -0,0 +1,3 @@ +import {plain} from './tools.js' + +export const clone = plain(a => a) diff --git a/src/numbers.js b/src/numbers.js new file mode 100644 index 0000000..2f6a5ec --- /dev/null +++ b/src/numbers.js @@ -0,0 +1 @@ +export * as numbers from './number/all.js'