origamitower / folktale

[not actively maintained!] A standard library for functional programming in JavaScript
https://folktale.origamitower.com/
MIT License
2.04k stars 102 forks source link

Build instructions #212

Closed jk121960 closed 5 years ago

jk121960 commented 5 years ago

I am using folktale In NetSuite SuiteScript 2.0 which is using the Rhino 1.7 JS engine and a modified requireJS module. I obtained a copy of folktale 2.0 from a CDN. 1. Can I be pointed to where I can make my own build so I can use the latest version? Any help with this would be great thanks

Steps to reproduce

I got the build I am using at https://cdnjs.com/libraries/folktale

Expected behavior

Observed behaviour

(Describe what happened instead)# Environment

(Describe the environment where the problem happens. This usually includes:

Additional information

(Anything else you feel relevant to the issue)

robotlolita commented 5 years ago

The easiest way is probably by using Browserify.

$ npm install folktale@latest browserify
$ ./node_modules/.bin/browserify -r folktale -s folktale -o folktale.js

This will generate a packaged folktale.js file that you can use with AMD modules, CommonJS modules, or systems that don't support either type of modules (folktale will be a global variable there).

jk121960 commented 5 years ago

thanks, very much, does this also minify

jk121960 commented 5 years ago

Sorry I'm a dope I will work it out thanks again

jk121960 commented 5 years ago

I created the file and it ran with no errors but when I use it I get the same errors. I am attempting to use "resultToMaybe" and it throws an error "Cannot find function matchWith in object Error: 1. (folktale.min.js$1314923$debugger.user#2639)" as the locations differ I have included the code block it is pointing to, It is pointing to the return aResult.matchWith statement in

    var resultToMaybe = function resultToMaybe(aResult) {
        return aResult.matchWith({
            Error: function Error(_ref) {
                var _ = _ref.value;
                return Nothing();
            },
            Ok: function Ok(_ref2) {
                var value = _ref2.value;
                return Just(value);
            }
        });
    };
    module.exports = resultToMaybe;
},{"../maybe/maybe":74}],31:[function(require,module,exports){
    'use strict';

I have loaded the es5 and es6 shims along with babel/polyfill, I appreicate your help with this. This library is helping me solve some annoying gaps in my data flow. thanks

jk121960 commented 5 years ago

Ok, Apparently it has something to do with how you retrieve "resultToMaybe", I was able to reproduce the error in Node by using object dot syntax so in other words getting to resultToMaybe via folktale.conversions.resultToMaybe. So it isn't the code it's the approach that I have to use for access to different portions of the code. OK thanks, I will work on it and figure it out.