Git Product home page Git Product logo

node.js_design_patterns_second_edition_code's People

Contributors

bassemghoniem avatar evildead avatar koresar avatar lmammino avatar packt-itservice avatar praju89 avatar williemaddox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node.js_design_patterns_second_edition_code's Issues

Chapter03/04_web_spider_v2

The spiderLinks function is supposed to be asynchronous, but it seems that the callback will be executed synchronously in case utilities.getPageLinks(currentUrl, body) returns an empty array.

Chapter 8 / module 14

When I start the API and web server, both start without issue. However, when I navigate a browser to localhost:300, the terminal responds with "TypeError: loadPropsOnServer is not a function."

When I remove .default from require('async-props').default and run both the API and web server, then navigate the browser to that page, the page hangs and here is a response in the web server terminal:

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).

Any clues?

promisify

The promisify function (Chapter04/01_promisify.js) contains a reference to the arguments variable in the callback which happens to be an arrow function (with lexical arguments).

Please find attached a test which demonstrates the problem.

Thank you.

test.js.txt

createProxy

The createProxy function (Chapter03/09_proxy_c) has a reference to this, in the patched version of the hello method, which happens to be an arrow function (with lexical this).

Please find a test attached to demonstrate the problem. Thank you.

test.js.txt

12_react_server_side_rendering fails to runs

For the section above in chapter 8, the book states use "node server" to start the server.

The source code readme , however, states "you need to run the server using babel-cli: 'node_modules/.bin/babel-cli server.js'"

Neither of them work and both return the following error: "let markup = ReactDom.renderToString(<Router.RouterContext {...renderProps} />);

SyntaxError: Unexpected token < "

bug in example 06_web_spider_v4

call spider function with nesting large than 1 would't work as expected
757x 7 8ke3z at 0 j3

93rep076 e2n a3b as nv
only two page had been download. and the callback never been call

it may be good to fix sth. for chapter04 promisify.js

i run cmd with your code:

$ node spider.js http://frps.eflora.cn/frps/Rosales

then a err comes--the file content i write to is undefined{1} .

function dowload(){
//...
 writeFile(filename, body))//{1}
//...
}

i think it may be good to change sth in :

  • add another _agruments to save the aguments for function promisified({1})
  • use the var at ({2},{3}) ,not agruments
    since here a function too, it may have its own arguments ({0})

-or change (not testing) args.push(function(err, result) { ...} to args.push((err, result)=>{...}

function promisify (callbackBasedApi) {
  return function promisified() {
    const args = [].slice.call(arguments);
    const _arguments = arguments; //{1}
    return new Promise((resolve, reject) => {  
      args.push(function(err, result) {     //{0}
        if(err) {
          return reject(err);       
        }
        if(_arguments.length <= 1) {       //{2}
          resolve(result);
        } else {
          resolve([].slice.call(_arguments, 1)); //{3}
        }
      });
      callbackBasedApi.apply(null, args);    
    });
  }
};

it may lead to the result of request operation in download function:

function dowload(){
//...
return request(url)
    .then(response => {
      body = response.body;
      //console.log(JSON.stringify(response));
     //the response is an array with length 2 . But it expect to an object since `request(url)`
    })
//...
}

thanky you !

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.