0.9.1 • Published 6 months ago

elf-help v0.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Elf Help

Tests Status NPM Version NPM Last Update License

Your very own helper elf; tools and functions to help with problems that may be encountered during advent of code.

Usage

All major features can be accessed through the default elf import:

import elf from "elf-help";

All major and minor features can also be accessed as named imports:

import { linesIntersect2D, ElfCartesianError } from "elf-help";

Features

Cartesian

FeatureDescription
coordCreates a coordinate object, either 2D or 3D
coordinateClone of the coord function (only available through default import)
isCoordinate2DVerifies that an object is of the Coordinate2D type
isCoordinate3DVerifies that an object is of the Coordinate3D type
lineCreate a line object, either 2D or 3D
isLine2DVerifies that an object is of the Line2D type
isLine3DVerifies that an object is of the Line3D type
linesIntersect2DChecks if 2 lines intersect in a 2D plane (3D lines can be evaluated on the xy plane)
ElfCartesianErrorError thrown by cartesian features
TypeDescription
Dimention2DThe dimentions of a 2D space
Dimention3DThe dimentions of a 3D space
Coordinate2DA 2 dimentional coordinate
Coordinate3DA 3 dimentional coordinate
Line2DA 2 dimentional line
Line3DA 3 dimentional line

Fraction

FeatureDescription
new FractionCreates a new Fraction object
fractionClone of new Fraction
Fraction.addAdds together two fractions
Fraction.subtractSubtracts two fractions
Fraction.multiplyMultiplies together two fractions
Fraction.divideDivides two fractions
Fraction.valueReturns the number representation of the fraction
ElfFractionErrorError thrown by fraction features

Iterate

FeatureDescription
permutationsReturns all permutations of a list, optionally limited to n-length permutations
combinationsReturns all combinations of a list, optionally limited to n-length combinations
rotateReturns all copy of an array rotated n steps
zipCombines two same length arrays
countCounts all elements of an array
ElfIterateErrorError thrown by iterate features

Math

FeatureDescription
sumReturns the sum of all provided numbers
productReturns the product of all provided numbers
gcdFinds the Greatest Common Divisor of two numbers
lcmFinds the Lowest Common Multiple of two numbers
factorialReturns the factorial of a number
divisorsReturns all divisors of a positive integer
new MatrixCreates a new Matrix object
matrixClone of new Matrix
Matrix.getGets the element of the matrix for a given x and y
Matrix.isSquareIf the matrix width is equal to the height
Matrix.validateValidates that the matrix has the same width for all rows (i.e. is a valid matrix)
Matrix.determinantFinds the determinant of a square matrix
ElfMathErrorError thrown by math functions
ElfMatrixErrorError thrown by matrix functions

Memoize

FeatureDescription
memoizeMemoizes a function

Multi map

FeatureDescription
new MultiMapCreates a new MultiMap object
multiMapClone of new MultiMap
MultiMap.setSets a value to the corresponding set of keys
MultiMap.getGets a value from the corresponding set of keys
MultiMap.deleteDeletes a value at the corresponding set of keys
MultiMap.sizeAmount of values stored in the map
ElfMultiMapErrorError thrown by multi map features

Ordered queue

FeatureDescription
new OrderedQueueCreates a new OrderedQueue object
orderedQueueClone of new OrderedQueue
OrderedQueue.addAdds a new element to the queue
OrderedQueue.dequeueRemoves the first element from the queue
OrderedQueue.lengthAmount of elements in the queue

Range

FeatureDescription
new RangeCreates a new Range object
rangeClone of new Range
Range.sizeThe number of elements included in the range
Range.sizeThe number of elements included in the range
Range.containsChecks if a number or Range is within the range
Range.overlapsChecks if a Range overlaps with the range
Can optionally return a detailed object with what's contained and outside of the range
ElfRangeErrorError thrown by range functions

Parse

FeatureDescription
parseNumbersFinds all numbers in a string
0.9.0

6 months ago

0.8.0

6 months ago

0.7.1

6 months ago

0.9.1

6 months ago

0.7.0

6 months ago

0.5.0

7 months ago

0.4.0

7 months ago

0.5.1

7 months ago

0.3.0

7 months ago