Git Product home page Git Product logo

couchify's Issues

Print warnings

Some examples:

  • User calls require() outside the body of design functions
  • Design function is dependent on code written in top-level.
    ...

Reduce functions are not properly extracted

The output json for the view when outputting dry mode into a file looks like this

{
      "map": " (function(){\n\nreturn function (doc) {\n\n    if (doc.amp && (doc.at || doc.until)) {\n      var date = doc.until || doc.at;\n      emit(doc.amp, new Date(date.time + date.offset).getTime());\n    }\n  };\n\nvar reduce = exports.reduce = function reduce() {\n  return function (keys, values) {\n    return Math.max(values);\n  };\n};\n\n}())",
      "reduce": " (function(){\n\nvar map = exports.map = function map(_ref) {\n  var emit = _ref.emit;\n  return function (doc) {\n\n    if (doc.amp && (doc.at || doc.until)) {\n      var date = doc.until || doc.at;\n      emit(doc.amp, new Date(date.time + date.offset).getTime());\n    }\n  };\n};\n\nreturn function (keys, values) {\n    return Math.max(values);\n  };\n\n}())"
    },

So the map function ends up with the reduce function in the body and vice versa.

This is the source for the view

export const map = ({emit}) => doc => {

  if(doc.amp && (doc.at || doc.until)) {
    const date = doc.until || doc.at;
    emit(doc.amp, new Date(date.time + date.offset).getTime());
  }

};

export const reduce = () => (keys, values) => Math.max(values);

And it gets transpiled to

(function(){

var map = exports.map = function map(_ref) {
  var emit = _ref.emit;
  return function (doc) {

    if (doc.amp && (doc.at || doc.until)) {
      var date = doc.until || doc.at;
      emit(doc.amp, new Date(date.time + date.offset).getTime());
    }
  };
};

return function (keys, values) {
    return Math.max(values);
  };

}())

And

(function(){

return function (doc) {

    if (doc.amp && (doc.at || doc.until)) {
      var date = doc.until || doc.at;
      emit(doc.amp, new Date(date.time + date.offset).getTime());
    }
  };

var reduce = exports.reduce = function reduce() {
  return function (keys, values) {
    return Math.max(values);
  };
};

}())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.