chart2txt 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart2txt.min.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -13
- package/dist/types.d.ts +1 -1
- package/package.json +45 -33
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.chart2txt=n():e.chart2txt=n()}(this,(()=>(()=>{"use strict";var e={921:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_SETTINGS=n.DEFAULT_ASPECTS=n.ZODIAC_SIGNS=void 0,n.ZODIAC_SIGNS=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"],n.DEFAULT_ASPECTS=[{name:"conjunction",angle:0,orb:5},{name:"opposition",angle:180,orb:5},{name:"trine",angle:120,orb:5},{name:"square",angle:90,orb:5},{name:"sextile",angle:60,orb:3}],n.DEFAULT_SETTINGS={includeSignDegree:!0,omitSigns:!1,houseSystem:"equal",includeHouseDegree:!1,omitHouses:!1,includeAscendant:!0,omitPoints:!1,aspectDefinitions:n.DEFAULT_ASPECTS,omitAspects:!1}}},n={};function t(o){var s=n[o];if(void 0!==s)return s.exports;var i=n[o]={exports:{}};return e[o](i,i.exports,t),i.exports}var o={};return(()=>{var e=o;const n=t(921);function s(e,t,o=[],s=n.DEFAULT_SETTINGS.includeSignDegree){const i=[...t?[{name:"Ascendant",degree:t}]:[],...e,...o].map((e=>{const t=function(e){const t=Math.floor(e/30)%12;return n.ZODIAC_SIGNS[t]}(e.degree);if(s){const n=Math.floor(e.degree%30);return`${e.name} is at ${n}° ${t}`}return`${e.name} is in ${t}`})).join(". ");return i?`${i}.`:""}function i(e,t,o,s=[],i=n.DEFAULT_SETTINGS.includeHouseDegree){const r=[...o,...s].map((n=>{const o=function(e,n,t){switch(e){case"equal":{const e=(n-t+360)%360;return{house:Math.floor(e/30)+1,degree:e%30}}case"whole_sign":{const e=(n-Math.floor(t/30)%12*30+360)%360;return{house:Math.floor(e/30)+1,degree:e%30}}}}(e,n.degree,t);return i?`${n.name} is at ${o.degree}° in house ${o.house}`:`${n.name} is in house ${o.house}`})).join(". ");return r?`${r}.`:""}function r(e,t={}){const o=Object.assign({},n.DEFAULT_SETTINGS,t);let r="Astrology Chart";const a=(c=e.location,u=e.timestamp,[c?`location: ${c}`:"",u?`at: ${u.toLocaleString()}`:""].filter((e=>""!==e)).join(", "));var c,u;if(a&&(r+=` (${a})`),r+=":\n\n",o.omitSigns||(r+=s(e.planets,o.includeAscendant&&e.ascendant?e.ascendant:void 0,o.omitPoints?[]:e.points,o.includeSignDegree)),o.omitHouses||void 0===e.ascendant||(r+="\n\n"+i(o.houseSystem,e.ascendant,e.planets,o.omitPoints?[]:e.points,o.includeHouseDegree)),!o.omitAspects){const n=function(e,n){const t=[];for(let o=0;o<n.length;o++)for(let s=o+1;s<n.length;s++){const i=n[o],r=n[s];let a=Math.abs(i.degree-r.degree);a>180&&(a=360-a);for(const n of e){const e=Math.abs(a-n.angle);if(e<=n.orb){t.push({planetA:i.name,planetB:r.name,aspectType:n.name,orb:e});break}}}return t}(o.aspectDefinitions,e.planets);n.length>0&&(r+="\n\n"+function(e){const n=e.map((e=>`${e.planetA} is in ${e.aspectType} with ${e.planetB} (orb: ${e.orb.toFixed(1)}°)`)).join(". ");return n?`${n}.`:""}(n))}return r}e.default=r})(),o=o.default})()));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,20 +7,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.chart2txt = chart2txt;
|
|
8
8
|
const constants_1 = require("./constants");
|
|
9
9
|
/**
|
|
10
|
-
* Determines the zodiac sign for a given
|
|
10
|
+
* Determines the zodiac sign for a given degree
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
13
|
-
const signIndex = Math.floor(
|
|
12
|
+
function getDegreeSign(degree) {
|
|
13
|
+
const signIndex = Math.floor(degree / 30) % 12;
|
|
14
14
|
return constants_1.ZODIAC_SIGNS[signIndex];
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Calculates the house for a given
|
|
17
|
+
* Calculates the house for a given degree, based on the ascendant
|
|
18
18
|
*/
|
|
19
|
-
function getHousePosition(houseSystem,
|
|
19
|
+
function getHousePosition(houseSystem, pointDegree, ascendant) {
|
|
20
20
|
switch (houseSystem) {
|
|
21
21
|
case 'equal': {
|
|
22
22
|
// House 1 starts at the ascendant
|
|
23
|
-
const housePosition = (
|
|
23
|
+
const housePosition = (pointDegree - ascendant + 360) % 360;
|
|
24
24
|
const house = Math.floor(housePosition / 30) + 1;
|
|
25
25
|
const degree = housePosition % 30;
|
|
26
26
|
return { house, degree };
|
|
@@ -29,7 +29,7 @@ function getHousePosition(houseSystem, longitude, ascendant) {
|
|
|
29
29
|
// House 1 starts at beginning of ascendant sign
|
|
30
30
|
const house1SignCusp = (Math.floor(ascendant / 30) % 12) * 30;
|
|
31
31
|
// Computation proceeds same as equal, using sign cusp
|
|
32
|
-
const housePosition = (
|
|
32
|
+
const housePosition = (pointDegree - house1SignCusp + 360) % 360;
|
|
33
33
|
const house = Math.floor(housePosition / 30) + 1;
|
|
34
34
|
const degree = housePosition % 30;
|
|
35
35
|
return { house, degree };
|
|
@@ -47,7 +47,7 @@ function calculateAspects(aspectDefinitions, planets) {
|
|
|
47
47
|
const planetA = planets[i];
|
|
48
48
|
const planetB = planets[j];
|
|
49
49
|
// Calculate the angular difference
|
|
50
|
-
let diff = Math.abs(planetA.
|
|
50
|
+
let diff = Math.abs(planetA.degree - planetB.degree);
|
|
51
51
|
if (diff > 180)
|
|
52
52
|
diff = 360 - diff;
|
|
53
53
|
// Check against each aspect type
|
|
@@ -72,13 +72,13 @@ function calculateAspects(aspectDefinitions, planets) {
|
|
|
72
72
|
*/
|
|
73
73
|
function formatPlanetSigns(planets, ascendant, points = [], includeDegree = constants_1.DEFAULT_SETTINGS.includeSignDegree) {
|
|
74
74
|
const ascPoint = ascendant
|
|
75
|
-
? [{ name: 'Ascendant',
|
|
75
|
+
? [{ name: 'Ascendant', degree: ascendant }]
|
|
76
76
|
: [];
|
|
77
77
|
const output = [...ascPoint, ...planets, ...points]
|
|
78
78
|
.map((planet) => {
|
|
79
|
-
const sign =
|
|
79
|
+
const sign = getDegreeSign(planet.degree);
|
|
80
80
|
if (includeDegree) {
|
|
81
|
-
const degree = Math.floor(planet.
|
|
81
|
+
const degree = Math.floor(planet.degree % 30);
|
|
82
82
|
return `${planet.name} is at ${degree}° ${sign}`;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
@@ -95,7 +95,7 @@ function formatPlanetHouses(houseSystem, ascendant, planets, points = [], includ
|
|
|
95
95
|
// TODO: house systems
|
|
96
96
|
const output = [...planets, ...points]
|
|
97
97
|
.map((planet) => {
|
|
98
|
-
const houseData = getHousePosition(houseSystem, planet.
|
|
98
|
+
const houseData = getHousePosition(houseSystem, planet.degree, ascendant);
|
|
99
99
|
if (includeDegree) {
|
|
100
100
|
return `${planet.name} is at ${houseData.degree}° in house ${houseData.house}`;
|
|
101
101
|
}
|
|
@@ -122,7 +122,7 @@ function formatAspects(aspects) {
|
|
|
122
122
|
*/
|
|
123
123
|
function formatLocationAndDate(location, timestamp) {
|
|
124
124
|
const locationString = location ? `location: ${location}` : '';
|
|
125
|
-
const timestampString = timestamp ? `at: ${timestamp.
|
|
125
|
+
const timestampString = timestamp ? `at: ${timestamp.toLocaleString()}` : '';
|
|
126
126
|
return [locationString, timestampString].filter((s) => s !== '').join(', ');
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
@@ -159,3 +159,5 @@ function chart2txt(data, settings = {}) {
|
|
|
159
159
|
}
|
|
160
160
|
return result;
|
|
161
161
|
}
|
|
162
|
+
// Default export for browser usage
|
|
163
|
+
exports.default = chart2txt;
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "chart2txt",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Convert astrological chart data to human-readable text",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"eslint-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "chart2txt",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Convert astrological chart data to human-readable text",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"browser": "dist/chart2txt.min.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc && webpack",
|
|
10
|
+
"build:tsc": "tsc",
|
|
11
|
+
"build:webpack": "webpack",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"lint": "eslint src/**/*.ts",
|
|
14
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\""
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"astrology",
|
|
18
|
+
"chart",
|
|
19
|
+
"text"
|
|
20
|
+
],
|
|
21
|
+
"homepage": "https://github.com/simpolism/chart2txt",
|
|
22
|
+
"author": "simpolism <simpolism@gmail.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/jest": "^29.5.0",
|
|
26
|
+
"@types/node": "^18.0.0",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
28
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
29
|
+
"eslint": "^8.0.0",
|
|
30
|
+
"eslint-config-prettier": "^8.0.0",
|
|
31
|
+
"jest": "^29.0.0",
|
|
32
|
+
"prettier": "^2.0.0",
|
|
33
|
+
"ts-jest": "^29.1.0",
|
|
34
|
+
"ts-loader": "^9.4.4",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"webpack": "^5.88.2",
|
|
37
|
+
"webpack-cli": "^5.1.4",
|
|
38
|
+
"terser-webpack-plugin": "^5.3.9"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"README.md"
|
|
44
|
+
]
|
|
45
|
+
}
|