https://github.com/easyQML/lodash.qml
Simple Lodash wrapper to ease usage in QML
https://github.com/easyQML/lodash.qml
javascript lodash qml wrapper
Last synced: 14 days ago
JSON representation
Simple Lodash wrapper to ease usage in QML
- Host: GitHub
- URL: https://github.com/easyQML/lodash.qml
- Owner: easyQML
- License: mit
- Created: 2018-04-02T19:16:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-11-05T21:13:51.000Z (27 days ago)
- Last Synced: 2025-11-05T23:24:20.987Z (27 days ago)
- Topics: javascript, lodash, qml, wrapper
- Language: JavaScript
- Homepage:
- Size: 105 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-qt-qml - qml-lodash - Simple [Lodash](https://lodash.com) wrapper to ease its usage in QML. (JavaScript)
README
# [Lodash](https://lodash.com/) for QML
[](https://github.com/GooRoo/ukrainian-shields)
This is a simple [Lodash](https://lodash.com/) wrapper for QML.
The installation process is not quite convenient yet, but stay tuned :) Maybe, I will update it in a few centuries.
## Installation
### Get the wrapper source
```sh
$ mkdir 3rdParty
$ cd 3rdParty
$ git clone https://github.com/easyQML/lodash.qml.git
```
### Get the Lodash itself
I've bundled the latest available version (which is 4.17.5) with the wrapper, but I strongly recommend you to re-generate it with the freshest one:
```sh
$ npm install -g lodash-cli
$ cd qml/lodash
$ lodash exports="none" iife=";(function () {%output% root._ = _; }.call(this));" -o lodash.js
```
### Update your QML import path
Please, refer to the [official documentation](http://doc.qt.io/qt-6/qtqml-syntax-imports.html#qml-import-path). I tried it with both local file-system paths and Qt Resource system paths, and it works.
## Usage
```qml
import QtQuick
import QtQuick.Window
import lodash // import the library
Window {
visible: true
width: 640
height: 480
title: qsTr('Hello Lodash')
Component.onCompleted: {
function megaprint(v) {
console.log(JSON.stringify(v))
}
// and it magically works here who knows why:
megaprint(
_.partition([1, 2, 3, 4], n => n % 2)
)
megaprint(
_([1, 2, 3]).map(n => n * 2)
)
}
}
```
Output
```
qml: [[1,3],[2,4]]
qml: [2,4,6]
```
## License
[Lodash](https://lodash.com/) library is distributed under [MIT license](https://lodash.com/license), so my outstanding three lines of code follow the same path: [LICENSE](LICENSE).