Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Utkarsh Sinha
    @liquidmetal
    babeljs.io down - do I need that for using trine?
    Utkarsh Sinha
    @liquidmetal
    okay - it isn't down.
    afilp
    @afilp
    Hi
    Just an ES6 modules question
    I use Babel and browserify for modules, but I would like to change all "require" to "import"
    So, I have this require inside the code:
    var test = require('./test');
    And inside test.js I have this:
    (function() {
    ...some code here...
    class myClass {
    ...more code here...
    }
        module.exports = new myClass();
    }).call(window);
    I changed the module.exports to export default new myClass();
    and the require to import('./test');
    But it does not work. Do I need some kind of polyfill?
    Jaeho Lee
    @sairion
    @af7 Babel gitter room would be more appropriate place to ask, but how does it fail?
    I don't think you need IIFE block to wrap after all
    afilp
    @afilp
    Thx @sairion
    Gorm Casper
    @casperin

    What's the easiest way to mess around with this library? If I want to be able to have a file like this:

    import map from 'trine/src/iterable/map'; // require is fine too
    console.log([1,2,3]::map(someFn));

    What's the compile step? ... Or am I doing it completely wrong?

    Gaetano Checinski
    @nikhedonia
    you could use babel-node --stage 0 --optional runtime myfile
    babel-runtime and babel-node must be installed in this case
    Gorm Casper
    @casperin
    Odd error: ReferenceError: The version of babel-runtime of undefined that you have installed does not match the babel version of 5.0.8 -- Pretty sure I just installed it babel-runtime@5.5.8
    Thanks though :)
    Jussi Kalliokoski
    @jussi-kalliokoski
    if you want to just mess around, I recommend creating a new directory, npm init there followed by npm i --save babel babel-runtime trine , then ./node_modules/.bin/babel-node --stage 0 myfile (--optional runtime shouldn't be required)
    I'm hoping to add a Trine-enabled Babel REPL to the website soon as well - that should enable "just messing around" type of trying out the library. :)
    btw, you should also import { map } from 'trine/iterable/map'; instead - trine exports things as named exports whereas the import foo from 'foo' syntax imports the default export of the 'foo' module under the identifier foo.
    Filip Stachura
    @filipstachura
    Hi guys! Is there any way to use trine in TypeScript?
    Jussi Kalliokoski
    @jussi-kalliokoski
    @filipstachura Hi Filip! Let's try and be as inclusive as possible and use gender neutral terms. :) Currently Trine doesn't expose the type definitions because TS / flow are lacking the possibility to annotate this other than automatically inside class declarations. However, with some tinkering you might be able to get Trine to work with TS, albeit AFAIK TS doesn't support the function bind syntax so the API will be quite awkward ( "babbca"::sortAlphabetically()::uniq()::head(2) vs head.call(uniq.call(sortAlphabetically.call("babbca")), 2) ). Maybe propose the function bind syntax to be added to TypeScript? ;)
    Barney Carroll
    @barneycarroll
    @jussi-kalliokoski just dropping in to say Trine has been an utter revelation for me
    So many Javascript APIs I've been struggling with for so long, I think I can fix, but then realise they're just fundamentally ugly because of language restrictions… and then data::arbitraryFn shows up. Genius. Fixes so much stuff, I hardly know where to start.
    :clap:
    Jussi Kalliokoski
    @jussi-kalliokoski
    @barneycarroll thanks, glad to hear that! but most of the credit goes to the syntax proposal that makes Trine possible :smile:
    riding on the giants' shoulders here
    Barney Carroll
    @barneycarroll
    …Or rather, lots of normal sized people, all stacked on top of one another ;)
    But the pattern at the core of Trine is inspirational
    TBH I'm mostly interested in applying the pattern on decorators for my application code
    Jussi Kalliokoski
    @jussi-kalliokoski
    correct, albeit that sounds a bit like oppression :laughing:
    Barney Carroll
    @barneycarroll
    Hehe
    Filip Stachura
    @filipstachura
    @jussi-kalliokoski Thanks for the feedback! BTW AFAIK term guys is inclusive (https://en.wiktionary.org/wiki/guys), at least in non formal conversations.
    Filip Stachura
    @filipstachura
    FYI: Here's appropriate issue in TypeScript repository: Microsoft/TypeScript#3508
    Barney Carroll
    @barneycarroll
    An interesting aspect of seamless binding is how it becomes far easier to rationalise about decorating functions
    Chuck in Symbols and you get some really powerful stuff
    Jussi Kalliokoski
    @jussi-kalliokoski
    @filipstachura I don't personally find it non-inclusive personally either, but it's not me I'm trying to include, and I know that a lot of people do find it non-inclusive. It's an easy thing to replace so if it has the chance to make people feel more welcome, I think it's worth the effort. :)
    Eh, was going for a milder smiley but that works too :D
    Nice, thanks for the link! Subscribed! Hopefully will be able to support TS soon too.
    Jussi Kalliokoski
    @jussi-kalliokoski
    @barneycarroll decorating functions as in "functions that decorate" or "adding decorators to functions"?
    yep - with symbols you get "sort of" private properties on pure data allowing encapsulation without classes
    Jussi Kalliokoski
    @jussi-kalliokoski
    then again, Symbols can be enumerated as well - a more powerful model at encapsulating data is functions, using the uniqueness of objects allowing for the encapsulation of the secret as well:
    "use strict";
    
    function hide (data, secret) {
        function hidden (attemptedSecret) {
            if ( attemptedSecret === secret ) {
                return data;
            } else {
                throw new Error("Attempt to access data with invalid secret");
            }
        }
    
        return hidden;
    }
    
    var secret = {};
    var hidden = hide({ foo: "1" }, secret);
    
    console.log(hidden(secret).foo); // "1"
    hidden({}) // Error
    Gaetano Checinski
    @nikhedonia
    how does exactly prepublish work? - how do i genereate the missing doc ? - should i care?
    Jussi Kalliokoski
    @jussi-kalliokoski
    npm run prepublish - if it doesn't error should be ok
    Gaetano Checinski
    @nikhedonia
    in my case(see PR #37) it complains, about a missing jsdoc for zip
    Gaetano Checinski
    @nikhedonia
    ok i cleaned up my mess ;P
    Karlin Fox
    @karlin
    Hi! Is there any convenient way to import everything in trine at once (for manual use in babel-node repl)?