@turing-machine-js/builder 0.3.0-alpha.4 → 2.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turing-machine-js/builder",
3
- "version": "0.3.0-alpha.4",
3
+ "version": "2.0.0-alpha.0",
4
4
  "description": "A turing machine builder",
5
5
  "author": "Ruslan Gilmullin <mellonis14@gmain.com>",
6
6
  "homepage": "https://github.com/mellonis/turing-machine-js#readme",
@@ -22,13 +22,8 @@
22
22
  "builder"
23
23
  ],
24
24
  "dependencies": {
25
- "@turing-machine-js/machine": "^0.3.0-alpha.4"
25
+ "@turing-machine-js/machine": "^2.0.0-alpha.0"
26
26
  },
27
- "main": "dist/index.cjs.js",
28
- "module": "dist/index.es.js",
29
- "scripts": {
30
- "build": "rollup -c ../../rollup.config.mjs",
31
- "test": "jest --colors"
32
- },
33
- "gitHead": "46f086aced8630b3c5f7d5e1585dacc6735d7666"
27
+ "module": "dist/index.js",
28
+ "gitHead": "eac8ba0029090bdbd64f72566657400101fd587e"
34
29
  }
package/dist/index.cjs.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var e,t=require("@turing-machine-js/machine"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;const n={L:t.movements.left,R:t.movements.right,S:t.movements.stay},o=Symbol("reference"),s=Symbol("state");module.exports=function({alphabetString:e,initialState:l,finalStateList:m,states:r}){const c=new t.Alphabet({symbolList:e.split("")}),i=new a({tapeBlock:new t.TapeBlock({alphabetList:[c]})}),{symbol:b}=i.tapeBlock;let y=m.reduce((e,a)=>({...e,[a]:{[s]:t.haltState,[o]:t.haltState}}),{});return Object.keys(r).forEach(e=>{null!=r[e]&&(y[e]={[o]:new t.Reference})}),Object.keys(r).forEach(e=>{if(null!=r[e]){const a={};Object.keys(r[e]).forEach(s=>{if(!c.has(s))throw new Error("invalid state declaration");let l=r[e][s].symbol;l===s&&(l=t.symbolCommands.keep),l===c.blankSymbol&&(l=t.symbolCommands.erase);const m=n[r[e][s].movement];if(!m)throw new Error("invalid state declaration");const i=y[r[e][s].state][o];a[b([s])]={command:{symbol:l,movement:m},nextState:i}});const l=new t.State(a);l.name=e,y[e][s]=l,y[e][o].bind(l)}}),y=Object.keys(y).reduce((e,t)=>({...e,[t]:y[t][s]}),{}),[i,y[l],y]};
package/dist/index.es.js DELETED
@@ -1 +0,0 @@
1
- import e,{Alphabet as t,TapeBlock as n,haltState as a,Reference as o,symbolCommands as s,State as l,movements as r}from"@turing-machine-js/machine";const i={L:r.left,R:r.right,S:r.stay},c=Symbol("reference"),m=Symbol("state");export default function({alphabetString:r,initialState:b,finalStateList:f,states:y}){const h=new t({symbolList:r.split("")}),d=new e({tapeBlock:new n({alphabetList:[h]})}),{symbol:w}=d.tapeBlock;let k=f.reduce((e,t)=>({...e,[t]:{[m]:a,[c]:a}}),{});return Object.keys(y).forEach(e=>{null!=y[e]&&(k[e]={[c]:new o})}),Object.keys(y).forEach(e=>{if(null!=y[e]){const t={};Object.keys(y[e]).forEach(n=>{if(!h.has(n))throw new Error("invalid state declaration");let a=y[e][n].symbol;a===n&&(a=s.keep),a===h.blankSymbol&&(a=s.erase);const o=i[y[e][n].movement];if(!o)throw new Error("invalid state declaration");const l=k[y[e][n].state][c];t[w([n])]={command:{symbol:a,movement:o},nextState:l}});const n=new l(t);n.name=e,k[e][m]=n,k[e][c].bind(n)}}),k=Object.keys(k).reduce((e,t)=>({...e,[t]:k[t][m]}),{}),[d,k[b],k]}