Kselax.ru

Hacker Kselax – the best hacker in the world

Menu
  • Blog
  • Contacts
  • wp plugin generator
  • English
    • Русский
Menu

Tag: node.js javascript

node.js fs – sclerotic

Posted on 12 December, 201816 February, 2019 by admin

  #How to read write files synchronously with fs

1
2
3
4
5
6
7
8
9
10
11
const fs = require('fs')
 
const str = '1Hello world!'
 
// save data
fs.writeFileSync(`${__dirname}/data.html`, str)
 
// read data
const d = fs.readFileSync(`${__dirname}/data.html`, 'utf8')
 
console.log('d = ', d) // d =  1Hello world!

  #How to read write files asynchronously with fs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const fs = require('fs')
 
const str = 'Hello world!'
 
// save data
fs.writeFile(`${__dirname}/data.html`, str, err => {
  if (err) throw err
  console.log('saved');
})
 
// read data
fs.readFile(`${__dirname}/data.html`, 'utf8', (err, data) => {
  if (err) throw err
  console.log('data = ', data); // data =  Hello world!
})

    #How to check existence of files Sometimes we have to know whether a file exists or not. To do this we’ll be using a node.js fs module. We could check synchronously by using and…

Read more

How to enable babel with nodejs and express

Posted on 28 November, 201829 November, 2018 by admin

How to set up node.js with a ES6 support. You have to use them to modules that will allow you to wrap the server in a babel wrapper and the code will be work.

Read more
graphql

How to use graphql in node.js

Posted on 14 November, 201814 November, 2018 by admin

Graphql is a query language for an API link graphql.js documentation link It is usually used with express by using module express-graphql link The sense of using at first we create a schema and in a graphql language then we create a root this is a variable that has handlers for each element in a schema….

Read more
template engine

JavaScript templates for rendering pages

Posted on 1 November, 20183 November, 2018 by admin

Exists many JavaScript templates like handlebars, ejs, pug, etc. In this article I’ll overview some templates that I’ve used first of all it’s my the first template handlebars, I use the module express-handlebar   links: How to integrate express with pug. The official guide link consolidate.js link Github repository with examples of this article link  …

Read more

Where to start creating a node.js app. The detailed instruction for a newbie.

Posted on 31 October, 201831 October, 2018 by admin

How to create a node.js app and where to start the newbies often ask these questions. In this article, we’ll try figuring out how it is going on. Node.js app has a few parts. It has always a config file.   The content table: Create a config file   #Create a config file We use…

Read more

How to use NPM. The main commands for a newbie

Posted on 31 October, 201831 October, 2018 by admin

NPM is a node package manager, which is used for installing removing packages from the NPM repository link. You can publish your own packages there as well.   The content table: NPM the common functionality How to use npm scripts #NPM the common functionality Create a package.json file we use the command

1
npm init

  Install…

Read more
promises

How to use promises in JavaScript

Posted on 8 August, 201814 February, 2019 by admin

The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. It is used for getting some data from the callback function in some determined function. Promise.all, or .then. content talbe: Creating a promise Using a promise for getting data from two and more callbacks How to use a…

Read more

Categories

  • bash (1)
  • English (9)
  • JavaScript (4)
  • node.js (22)
  • photoshop (1)
  • php (3)
  • React (9)
  • sclerotic (6)
  • Ubuntu (10)
  • Uncategorized (13)
  • Wordpress (1)

Tags

Ajax apache2 automation bash chrome-extension command line editor ejs email English English-grammar framework functions git graphql handlebars hybrid app installation javascript js linux newbie node.js node.js javascript nodemailer npm objects Performance php phpmyadmin playonlinux promise rabbitmq React react-router redis reverse-proxy session shell socket.io sublime text 3 time zones ubuntu unity webpack

Recent Comments

  • damien on How to install npm and nodejs the latest versions on ubuntu
  • Cam on How to install npm and nodejs the latest versions on ubuntu
  • Pierre on socket.io with apache as a reverse proxy on the CentOS
  • admin on How to use react-router with a few languages
  • admin on How to install npm and nodejs the latest versions on ubuntu
©2021 Kselax.ru Theme by ThemeGiant