Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LeaveNhA/0491682924732cbbcfa5bbd8738cccee to your computer and use it in GitHub Desktop.
Save LeaveNhA/0491682924732cbbcfa5bbd8738cccee to your computer and use it in GitHub Desktop.
// 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