Check it out:

https://github.com/monksy/tetris-engine

The only thing that it’s missing is interactivity, graphics, rotations, and animations.