bindu 1.6.0 → 1.7.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/ChangeLog CHANGED
@@ -1,3 +1,16 @@
1
+ 2025.12.14, v1.7.1
2
+
3
+ feature:
4
+ - 91dcacd bindu: sandhi: vriddhi: improve support
5
+
6
+ 2025.12.14, v1.7.0
7
+
8
+ fix:
9
+ - 80a235f bindu: sandhi: apply-ayadaya
10
+
11
+ feature:
12
+ - cb04966 bindu: type: iast
13
+
1
14
  2025.12.12, v1.6.0
2
15
 
3
16
  feature:
package/README.md CHANGED
@@ -27,8 +27,12 @@ npm i bindu -g
27
27
  import {bindu} from 'bindu';
28
28
 
29
29
  bindu('प्रतिएक');
30
- // returns {code: 'प्रत्येक';A'}
30
+ // returns {code: 'प्रत्येक'}
31
+ bindu('द्रौपदी अश्वम्', {
32
+ type: 'iast',
33
+ });
31
34
 
35
+ // returns {code: 'draupadyaśvam'}
32
36
  const {places} = bindu('प्रतिएक', {
33
37
  fix: false,
34
38
  });
package/lib/bindu.js CHANGED
@@ -5,6 +5,7 @@ import {postProcess, preProcess} from './process.js';
5
5
 
6
6
  export const toSLP1 = (a) => Sanscript.t(a, 'devanagari', 'slp1');
7
7
  export const toDevanagari = (a) => Sanscript.t(a, 'slp1', 'devanagari');
8
+ export const toIAST = (a) => Sanscript.t(a, 'slp1', 'iast');
8
9
 
9
10
  export const bindu = (text, overrides = {}) => {
10
11
  const {fix = true, type} = overrides;
@@ -25,6 +26,12 @@ export const bindu = (text, overrides = {}) => {
25
26
  places,
26
27
  };
27
28
 
29
+ if (type === 'iast')
30
+ return {
31
+ code: toIAST(cleanText),
32
+ places,
33
+ };
34
+
28
35
  return {
29
36
  code: toDevanagari(cleanText),
30
37
  places,
@@ -1,15 +1,23 @@
1
1
  import {operator} from 'putout';
2
- import {avagraha} from '../../symbols.js';
3
2
 
4
3
  const {remove} = operator;
5
4
 
6
5
  export const report = () => `ayādayaḥ`;
7
6
 
8
7
  export const fix = ({path, next, name, nextName}) => {
9
- const joint = createJoint(name, nextName);
10
-
11
- path.node.name = `${name.slice(0, -1)}${joint}${nextName.slice(1)}`;
12
8
  remove(next);
9
+
10
+ if (nextName.startsWith('a')) {
11
+ path.node.name = `${name}${nextName.slice(1)}`;
12
+ return;
13
+ }
14
+
15
+ if (nextName.startsWith('ya')) {
16
+ path.node.name = `${name.slice(0, -1)}${nextName.slice(1)}`;
17
+ return;
18
+ }
19
+
20
+ path.node.name = `${name.slice(0, -1)}i${nextName.slice(1)}`;
13
21
  };
14
22
 
15
23
  export const traverse = ({push}) => ({
@@ -22,15 +30,10 @@ export const traverse = ({push}) => ({
22
30
  const {name} = path.node;
23
31
  const nextName = next.node.name;
24
32
 
25
- const last = name
26
- .at(-1)
27
- .toLowerCase();
28
-
29
- const first = nextName
30
- .at(0)
31
- .toLowerCase();
33
+ if (!name.endsWith('ya'))
34
+ return;
32
35
 
33
- if (!/[aiueo]/.test(last) || !/[aiueo]/.test(first))
36
+ if (!/^(i|a|ya)/.test(nextName))
34
37
  return;
35
38
 
36
39
  push({
@@ -41,16 +44,3 @@ export const traverse = ({push}) => ({
41
44
  });
42
45
  },
43
46
  });
44
-
45
- function createJoint(name, nextName) {
46
- if (name.endsWith('a') && nextName.startsWith('e'))
47
- return 'aye';
48
-
49
- if (name.endsWith('a') && nextName.startsWith('o'))
50
- return 'ayau';
51
-
52
- if (name.endsWith('e') && nextName.startsWith('a'))
53
- return `e${avagraha.code}`;
54
-
55
- return '';
56
- }
@@ -5,7 +5,9 @@ const {remove} = operator;
5
5
  export const report = () => `vṛddhireci`;
6
6
 
7
7
  export const fix = ({path, next, name, nextName}) => {
8
- path.node.name = `${name.slice(0, -1)}A${nextName.slice(1)}`;
8
+ const joint = getJoint(nextName);
9
+
10
+ path.node.name = `${name}${joint}${nextName.slice(1)}`;
9
11
  remove(next);
10
12
  };
11
13
 
@@ -23,9 +25,12 @@ export const traverse = ({push}) => ({
23
25
  .at(-1)
24
26
  .toLowerCase();
25
27
 
26
- const [first, second] = nextName;
28
+ const [first] = nextName;
27
29
 
28
- if (last !== 'a' || first !== 'a' || !/[iu]/.test(second))
30
+ if (last !== 'a')
31
+ return;
32
+
33
+ if (!/[oe]/.test(first) && !/^a[iu]/.test(nextName))
29
34
  return;
30
35
 
31
36
  push({
@@ -36,3 +41,16 @@ export const traverse = ({push}) => ({
36
41
  });
37
42
  },
38
43
  });
44
+
45
+ function getJoint([first, second]) {
46
+ if (first === 'e')
47
+ return 'i';
48
+
49
+ if (second === 'i')
50
+ return '';
51
+
52
+ if (second === 'u')
53
+ return '';
54
+
55
+ return 'u';
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bindu",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Pāṇini Aṣṭādhyāyī",
5
5
  "main": "lib/bindu.js",
6
6
  "bin": {