import { createCanvas, loadImage } from 'canvas'
const image = await loadImage("https://рандомныйсайт/img.jpg", {
crossOrigin: "anonymous"
})
const canvas = createCanvas(500, 500)
const context = canvas.getContext('2d')
context.drawImage(image, 0, 0, canvas.width, canvas.width)
const pixelData = context.getImageData(1, 1, 1 ,1)
const deleted = [], updated = []
for (let oldidx = 0, newidx = 0; oldidx < current_data.length || newidx < new_data.length;) {
if (newidx >= new_data.length || current_data[oldidx]?.id < new_data[newidx].id) {
deleted.push(current_data[oldidx])
oldidx++
continue
}
if (oldidx >= current_data.length || current_data[oldidx].id > new_data[newidx]?.id || !lodash.isEqual(new_data[newidx], current_data[oldidx])) {
updated.push(new_data[newidx])
oldidx++
newidx++
continue
}
oldidx++
newidx++
}
const axios = require('axios').default
const axios = require('axios')
const _ = require('lodash')
const newArray = array_2
const oldArray = array_1
// возвращает новые и обновлённые данные
const changed = newArray.filter(newitem => {
const olditem = oldArray.find(o => o.id == newitem.id)
return !_.isEqual(newitem, olditem)
})
const deleted = oldArray.filter(olditem => {
const newitem = newArray.find(n => n.id == olditem.id)
return !_.isEqual(newitem, olditem)
}).filter(item => { // теперь нужно достать только удалённые данные, а обновлённые проигнорить.
const item = changed.find(cd => cd.name == item.name)
return !item
})
// npm i csv-parser
// npm i csv-writer
const fs = require('fs')
const csvParser = require('csv-parser')
const createCsvWriter = require('csv-writer').createObjectCsvWriter
const video = []
fs.createReadStream('./ссылка на файл.csv')
.pipe(csvParser())
.on('data', data => video.push(data))
.on('end', () => {
const movies = video.filter(video => video.TYPE == 'movie')
const serals = video.filter(video => video.TYPE == 'serials')
createCsvWriter({
path: 'папка/названиефайла.csv',
header: Object.keys(movies[0]).map(key => ({ id: key, title: key })) // не важно
}).writeRecords(movies)
createCsvWriter({
path: 'папка/названиефайла.csv',
header: Object.keys(serals[0]).map(key => ({ id: key, title: key }))
}).writeRecords(serals)
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import autoprefixer from 'autoprefixer'
import postcssColorMod from 'postcss-color-mod-function'
export default defineConfig({
plugins: [vue()],
css: {
postcss: {
plugins: [ autoprefixer, postcssColorMod ]
}
}
})