Created
April 21, 2021 11:25
-
-
Save LeaveNhA/0491682924732cbbcfa5bbd8738cccee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Developed by Seçkin KÜKRER (@LeaveNhA) for Javascript Topluluğu | |
// Değerleri isimli alanlara dönüştürmek için: | |
const mapWithKey = key => values => values.map(value => ({[key]: value})); | |
// Nesneleri birleştirmek için: | |
const mergeObjects = (obj1, obj2) => ({...obj1, ...obj2}); | |
// Veri serilerini eşli olarak yapılandırmak için: | |
const zip = (a, b) => a.map((m, j) => [m, b[j]]); | |
// Örnek kullanım: | |
// Verileri `name` isimli alanına taşıyoruz. | |
zip(mapWithKey('name')(['Ali', 'Ahmet', 'Kerem', 'Cemil']), | |
// Verileri `age` isimli alanına taşıyoruz. | |
mapWithKey('age')([12, 1, 3, 5])) | |
// Her bir nesneyi birleştiriyoruz. Not: Sıra korunmalı. | |
.map(([obj1, obj2]) => mergeObjects(obj1, obj2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment