bindu 1.6.0 → 1.7.0

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,11 @@
1
+ 2025.12.14, v1.7.0
2
+
3
+ fix:
4
+ - 80a235f bindu: sandhi: apply-ayadaya
5
+
6
+ feature:
7
+ - cb04966 bindu: type: iast
8
+
1
9
  2025.12.12, v1.6.0
2
10
 
3
11
  feature:
package/README.md CHANGED
@@ -27,7 +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
+
32
+ bindu('द्रौपदी अश्वम्', {
33
+ type: 'iast',
34
+ });
35
+ // returns {code: 'draupadyaśvam'}
31
36
 
32
37
  const {places} = bindu('प्रतिएक', {
33
38
  fix: false,
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
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bindu",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Pāṇini Aṣṭādhyāyī",
5
5
  "main": "lib/bindu.js",
6
6
  "bin": {