0.3.3 • Published 9 years ago
gcn_sample v0.3.3
gcn_sample
A geometry calculator in nodeJS.
install
# install
$ npm install gcn_sample
# run tests
$ npm test
# run tests with coverage
$ npm run test-covNote: I filed an issue on the buffer deprecation warning for covert.
api
calc(shape)
Calculates the geometry of the shape based on dimensions
Required argument
shapeObject
Required keys for shape
shapeString triangle|rectanglegeometryString area|circumferencedimensionsArray numbers
Required arguments for dimensions by shape and geometry
- Area of triangle
[base, height] - Circumference of triangle
[sideA, sideB, sideC] - Area of rectangle
[base, height] - Circumference of rectangle
[base, height]
totalAreaMultipleShapes(shapes)
Calculates the total area of shapes provided
Required argument
shapesArray Objects
Required keys for each shape
shapeString triangle|rectangle|circledimensionsArray numbers
Required arguments for dimensions by shape
- Area of triangle
[base, height] - Area of rectangle
[base, height] - Area of circle
[radius]
Example
var GCN = require('gcn_sample'),
gcn = new GCN(),
triangle = {
shape: 'triangle', geometry: 'circumference', dimensions: [5, 5, 5]
},
circumferenceOfTriangle = gcn.calc(triangle),
multipleShapes = [
{shape: 'triangle', dimensions: [6, 6]},
{shape: 'rectangle', dimensions: [10, 10]},
{shape: 'circle', dimensions: [5]}
],
totalArea = gcn.totalAreaMultipleShapes(multipleShapes);License
MIT