https://github.com/morgul/qtjs
An implementation of QList, QString and QHash ontop of Javascript's Array, String, and Object.
https://github.com/morgul/qtjs
Last synced: 3 months ago
JSON representation
An implementation of QList, QString and QHash ontop of Javascript's Array, String, and Object.
- Host: GitHub
- URL: https://github.com/morgul/qtjs
- Owner: Morgul
- License: mit
- Created: 2013-06-13T21:38:16.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-11T18:59:03.000Z (almost 12 years ago)
- Last Synced: 2025-01-28T01:23:01.140Z (4 months ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Qtjs
This is an implementation of some of Qt's core types, ontop of Javascript's core types. This project modifies the
prototypes of Array, String, and Object to adhere closer to QList, QString, and QMap. This makes Javascript much easier
to work with from inside QML.## But, isn't modifying prototypes bad?
Generally, yes. Modifying the prototypes of the core types is like changing the language's API. Anything you code against
it will only work with your changes, and things coded against the default api might break. In practice, I've found that
modifying the prototype is acceptible when you're adding a small number of functions you need globally. Still, in general,
I don't recommend it.So why do it? Simple. This is targeted at a _bare-bones QML Environment_. When writing QML, I don't want to have to fight
with Javascript, or change mental gears and use something like [lodash](http://lodash.com/). I'd rather use Qt's types,
or at the very least, Qt's API.That's what this is for.
## Why not make QList, QString and QMap work-alikes?
Great question. Mostly, because I'm a bit lazy, it's slightly more work, and you'll be wrapping values returned from Qt
in these custom types constantly.I have considered having a version of this library that does exactly that. So the developer can choose which method he'd
prefer. That's not what it does currently, but I'm open to it.## Unit tests
First, install node.js. Then, simply:
```bash
$ npm install
```Once that completes, you can run the unit tests with:
```bash
$ npm test
```This will run Karma, and try to launch Google Chrome. You can change what browser it launched in the config. Also, I
have it set to continuous integration mode, since that's the easiest for me while developing.## License
Licensed under the MIT license. See LICENSE for details.
## Inclusion in Qt
One of the goals for this project is to get this code included in Qt, as a nice extra. We'll see how that goes.