davidgtonge / underscore-query

MongoDB like query api for JavaScript Arrays

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lodash support

jgrenon opened this issue · comments

You indicate in your documentation that underscore-query can work with Lodash. I've tried it without much success. I had to change your hardcoded require('underscore') to require('lodash') in your factory immediate function.

(function(root, factory) {
    // Set up appropriately for the environment.
    if (typeof exports !== 'undefined') {
    // Node/CommonJS
        factory(root, exports, require('lodash'));
    } else if (typeof define === 'function' && define.amd) {
        // AMD
        define(['underscore', 'exports'], function(_, exports) {
        factory(root, exports, _);
    });
} else {
    // Browser globals
    factory(root, {}, root._);
}
}(this, function(root, exports, _) {

Do you see any way to do this without having to modify the code, which isn't a real solution actually.

i'll test it out. the actual code should be fine, its just this boilerplate wrapper that's the problem!

I agree, after changing underscore for lodash, everything’s work perfect. Just need to find a way to get the current value of _ from the node module registry. You can’t rely on require for that I guess.

On Sunday, November 3, 2013 at 3:57 PM, Dave Tonge wrote:

i'll test it out. the actual code should be fine, its just this boilerplate wrapper that's the problem!


Reply to this email directly or view it on GitHub (#2 (comment)).

Ok, just pushed quite a major refactor.
Its been in the works for a while, but just finished it off.
In module environments when you require the library it will return a function that accepts either underscore or lodash.
Its also possible to avoid "mixing in", if you don't want the library to touch underscore / lodash.
I've updated the documentation to refect this.

Let me know if you still have any issues.

Thanks