@sedd/utils

SEDD specific utilities that are common between client/server.

Stats

StarsIssuesVersionUpdatedCreatedSize
@sedd/utils
3.2.23 years ago4 years agoMinified + gzip package size for @sedd/utils in KB

Readme

Sedd Utils

SEDD specific utilities that are common between client/server.

Install

npm i -S @sedd/utils

Utils

This module provides the following utilitys

Progress

Progress is a simple data object ({ distance, diameter }) as recorded in the field. An array of progress objects is used to create the drill's segment status.

toVolume

Converts a progress object (distance in feet, diameter in inces) to volume (cubic yards). Note, it performs raw volume calcuation and does not account for over-drilling.

import { toVolume } from "@sedd/utils/progress";

toVolume({ distance: 100, diameter: 30 });

Segment

A segment is a link-list data structure which models the excavation state of a drill. A linked list is needed to properly perform segment math as new progress objects are added.

fromProgressArray

Converts an array of progress objects into a segment linked-list.

import { fromProgressArray } from "@sedd/utils/segment";

const segment = fromProgressArray([
  { diameter: 30, distance: 100 },
  { diameter: 30, distance: 100 }
])

toArray

Converts a segment linked-list into a segment array: an array of progress objects which have been properly added to each other based on business logic of how to properly sum progress objects.

import { toArray, fromProgressArray } from "@sedd/utils/segment";

const segment = fromProgressArray([
  { diameter: 10, distance: 100 },
  { diameter: 30, distance: 100 }
]);

const holeStatus = toArray(segment); // produces [{diamter: 30, distance: 100}]

toVolume

Converts a segment linked-list into total extracted volume.

import { toVolume, fromProgressArray } from "@sedd/utils/segment";

const segment = fromProgressArray([
  { diameter: 10, distance: 300 }
  { diameter: 20, distance: 780 }
]);

const volume = toVolume(segment); // produces 63.025778544239685

addProgressObject

import { addProgressObject, fromProgressArray } from "@sedd/utils/segment";

const segment = fromProgressArray([
  { diameter: 10, distance: 300 }
  { diameter: 20, distance: 780 }
]);

const progress = { diameter: 30, distance: 780 };

addProgressObject( segment, progress );

UUID

A set of functions to create deterministic UUIDS based on legacy or VP ids.

import {
  fromLegacyRigId
  fromLegacyUserId
  fromLegacyContractId
  fromLegacyDrillId
  fromLegacyPhaseId
  fromLegacyShiftId
  fromLegacyPhaseProgressId
  fromLegacyShiftEventId
  fromLegacyTimeCardId
  fromVpEmployeeId
  fromVpContractId
  fromVpDrillId
  fromVpPhaseId
} from "@sedd/utils/uuid";

fromLegacyRigId(4);

Dates

Commonly used date utilities.

import {
  minDate,
  maxDate,
  formatDateNoTime
} from "@sedd/utils/dates";

const min = minDate(null, new Date(), new Date(), new Date());
const max = maxDate(null, new Date(), new Date(), new Date());
const dateInYYYYMMDD = formatDateNoTime(new Date());

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.