gcn_sample

0.3.3 • Public • Published

gcn_sample

A geometry calculator in nodeJS.

install

# install 
$ npm install gcn_sample
# run tests 
$ npm test
# run tests with coverage 
$ npm run test-cov

Note: 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

  • shape Object

Required keys for shape

  • shape String triangle|rectangle
  • geometry String area|circumference
  • dimensions Array [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

  • shapes Array [Objects]

Required keys for each shape

  • shape String triangle|rectangle|circle
  • dimensions Array [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

Readme

Keywords

none

Package Sidebar

Install

npm i gcn_sample

Weekly Downloads

1

Version

0.3.3

License

MIT

Last publish

Collaborators

  • karlpokus