https://github.com/cjsaylor/baluster
Library to estimate baluster quantity and spacing for constructing railings.
https://github.com/cjsaylor/baluster
Last synced: 1 day ago
JSON representation
Library to estimate baluster quantity and spacing for constructing railings.
- Host: GitHub
- URL: https://github.com/cjsaylor/baluster
- Owner: cjsaylor
- Created: 2019-06-09T11:02:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-16T15:34:53.000Z (about 7 years ago)
- Last Synced: 2025-01-22T10:36:31.780Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://www.chris-saylor.com/baluster/
- Size: 320 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Baluster
Baluster is a javascript library to enable estimation of balusters and calculating the spacing to get an even distribution on a constructed railing.
> Note: Please consult your local building codes for maximum spacing requirements. This library assumes maximum spacing distance of 4".
## Usage
```
npm install baluster
```
For babel/webpack apps:
```js
import { estimateQuantity } from 'baluster'
console.log(estimateQuantity(41.625))
// 7
```
For nodejs (commonjs) apps:
```js
const { estimateQuantity } from 'baluster'
console.log(estimateQuantity(41.625))
// 7
```
## API
### `estimateQuantity`
```js
int estimateQuantity(
float widthBetweenPosts,
float balusterWidth = 1.75
)
```
Given `widthBetweenPosts` which is the measurement in inches measured on the interior of the posts, this will calculate the number of balusters needed.
---
### `calculateSpacing`
```js
float calculateSpacing(
float widthBetweenPosts,
int balusterQuantity,
float balusterWidth = 1.75
)
```
Calculate the spacing that is needed between each baluster to make them all equidistant.
Throws an exception if the `balusterQuantity` is not enough to satisfy maximum spacing requirements.
---
### spacingMeasurements
```js
array spacingMeasurements(
float widthBetweenPosts,
int balusterQuantity,
float balusterWidth = 1.75
)
```
As with `calculateSpacing`, this will specify the measurements for each baluster on the rail (measurement centered on the baluster).
---
### nearest16th
```js
int nearest16th(
float number
)
```
Utility method to calculate the nearest 16th of an inch.
```js
console.log(nearest16th(0.5))
// 8
```