thrustcurve-db
Advanced tools
Comparing version 0.3.15 to 1.0.0
@@ -1,5 +0,1 @@ | ||
// Should be able to do `export default from './thrustcurve-db.json'` from | ||
// here, right? | ||
import MOTORS from './thrustcurve-db.json'; | ||
export default MOTORS; | ||
export * from './util.js' | ||
export {default} from './thrustcurve-db.json'; |
{ | ||
"name": "thrustcurve-db", | ||
"version": "0.3.15", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "ThrustCurve.org model rocket motor and thrust curve data as a single JSON file", | ||
"main": "./index.js", | ||
"exports": { | ||
"import": "./index.js", | ||
"require": "./index.cjs" | ||
}, | ||
"types": "thrustcurve-db.d.ts", | ||
@@ -8,0 +11,0 @@ "files": [ |
@@ -9,3 +9,3 @@ # thrustcurve-db | ||
* Motor "availability" is exposed as the `discontinued` field (see https://github.com/JohnCoker/thrustcurve3/issues/35) | ||
* Where available, thrust curve data (from the 'download' endpoint) is included as a `samples` array. These are normalized to always have `[0, 0]` as the first data point. In cases where a motor has more than one thrust sample file the first "cert"(ified) file found is used, otherwise the samples are from whichever file the API returned first. (This typically isn't an issue since most thrust curves are very similar, but there are some cases where they differ significantly). | ||
* Where available, thrust curve data (from the "download" endpoint) is included as a `samples` array. These are normalized to always have `[0, 0]` as the first data point. In cases where more than one sample file is available for a motor, the first "cert"(ified) file found is used. Otherwise the samples are from whichever file the API return first. | ||
@@ -21,3 +21,3 @@ **License & Support** | ||
You know the drill ... | ||
### NPM | ||
@@ -28,41 +28,35 @@ ``` | ||
### Yarn | ||
``` | ||
yarn add thrustcurve-db | ||
``` | ||
## Usage | ||
### ES Modules | ||
```js | ||
import MOTORS, {parseDelays, unparseDelays} from 'thrustcurve-db'; | ||
import MOTORS from 'thrustcurve-db'; | ||
``` | ||
// `MOTORS` is a Motor[] array. | ||
### CommonJS | ||
```js | ||
const MOTORS = require('thrustcurve-db'); | ||
``` | ||
for (const motor of MOTORS) { | ||
// See `thrustcurve-db.d.ts` for Motor structure details. | ||
console.log(motor); // Spew data for ~1,100 motors to console | ||
} | ||
### CommonJS w/ `import()` (NodeJS) | ||
// parseDelays() parses a motor `delays` value to determine the | ||
// delay options. The returned Object has the following properties: | ||
// | ||
// times: Number[] array of possible delay times (seconds) | ||
// plugged: true if motor has a "Plugged" configuration | ||
// | ||
// Aerotech delays (S, M, L, X) are transformed as follows: | ||
// S -> 0-6 | ||
// M -> 0-10 | ||
// L -> 0-14 | ||
// X -> 0-18 | ||
// | ||
// Note: `times` are guaranteed to be unique and in ascending order. | ||
// E.g. `parseDelays('L, S')` and `parseDelays('1, 5, M, L')` will | ||
// produce the same result. | ||
Note: At present this requires you run `node` with the `--experimental-json-modules` flag | ||
parseDelays('S, 16, P'); // -> { | ||
// times: [0,1,2,3,4,5,6,16], | ||
// plugged: true | ||
// } | ||
```js | ||
const MOTORS = await import('thrustcurve-db'); | ||
``` | ||
// unparseDelays(parsed) is the inverse operation of parseDelays() (sort of). | ||
## Example | ||
unparseDelays({ | ||
times: [0,1,2,3,4,5,6,16], | ||
plugged: true | ||
}); // -> "0-6,16,P" | ||
After importing (above)... | ||
```js | ||
// Find all J motors currently in production | ||
MOTORS.filter(m => m.availability === 'regular' && m.impulseClass === 'J'); | ||
``` |
type ThrustPoint = [number, number]; | ||
type Samples = ThrustPoint[]; | ||
type ParsedDelays = { | ||
times: Number[], | ||
plugged: Boolean | ||
}; | ||
export function parseDelays(string) : ParsedDelays; | ||
export function unparseDelays(ParsedDelays) : string; | ||
export declare type Motor = { | ||
availability : 'regular' | 'OOP'; | ||
avgThrustN : number; | ||
@@ -22,3 +13,2 @@ burnTimeS : number; | ||
diameter : number; | ||
discontinued ?: boolean; | ||
impulseClass : string; | ||
@@ -33,3 +23,3 @@ infoUrl : string; | ||
propWeightG : number; | ||
samples ?: Samples; | ||
samples ?: ThrustPoint[]; | ||
sparky ?: boolean; | ||
@@ -36,0 +26,0 @@ totImpulseNs : number; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
1779843
5
122085
60