for (i in array){
(function (m) {
setTimeout(function () {
change(array[m])
}, 2000)
})(i)
}
npm i iconv-lite
const request = require('request'),
fs = require('fs'),
iconv = require('iconv-lite');
request({
url: 'https://litportal.ru/trial/txt/6376244.txt',
encoding: null,
body: 'Buffer'
}).pipe(iconv.decodeStream('win1251'))
.pipe(iconv.encodeStream('utf8'))
.pipe(fs.createWriteStream('file-in-utf8.txt'));
"use strict";
const {src, dest} = require("gulp");
const gulp = require("gulp");
const gulpCopy = require('gulp-copy');
const outputPath = "dist/";
var path = {
build: {
html: "dist/",
images: "dist/"
},
src: {
html: "src/*.html",
images: ['src/img/**/*.*']
}
}
function images() {
return src(path.src.images)
.pipe(gulpCopy(outputPath, {prefix: 1}))
.pipe(dest(path.build.images));
}
const build = gulp.series(images);
exports.images = images;
exports.default = build;
setEndTime(endTimeUnix * 1000);
console.log('endTime', endTime);
const timerInterval = setInterval(timer, 1000);
import express from 'express'
...
const app = express()
const PORT = process.env.PORT || 8080
...
app.listen(PORT, () => {
console.log('Server has been started on port ...')
})
app.listen(80, () => {
console.log('Server has been started on port ...')
})
<div className="todos" вот сюда>
<div key={todo.id} className="item-todo" >
useEffect(() => {
getTodos()
}, [вот тут])
useEffect(() => {
getTodos()
// eslint-disable-next-line
}, [])
export const getData = (axiosFunc, num, spinner = null) => (dispatch) => {
dispatch(setSpinner(spinner));
axiosFunc()
.then((response) => {
dispatch(setPosts(response.result, num));
})
.catch(console.log)
.finally(() => {
dispatch(closeSpinner());
});
};
// примеры вызова
getData (axiosGetBlog, 1, spinner)
getData (axiosGetPubl, 2, spinner)
getData (axiosGetMat, 3, spinner)
const startDate = new Date("2019-01-01") // ключевая дата
const inTmStamp = startDate.getTime()
const data = [
['Anton', 1352300800000],
['Igor', 1546300800000],
['Vasiliy', 1559300809800],
['Stephan', 1546300800000],
['Jose', 1446300800000],
]
function leadZero(str){ // добавляет ноль спереди, если цифра одна
return String(str).length<2 ? '0'+str : str
}
function formatTime(dt){
// нумерация месяцев с 0, поэтому +1
return dt.getFullYear() + '-' + leadZero(dt.getMonth()+1) + '-' + leadZero(dt.getDay())
}
const res = data.filter(arr => arr[1] < inTmStamp).map(arr => {
const dt = new Date(arr[1])
return {
'Дата создания': formatTime(dt),
'Сотрудник': arr[0]
}
})
console.log(JSON.stringify(res))