Skip to content

Instantly share code, notes, and snippets.

View AlonsoK28's full-sized avatar
👓
Learning Nest JS

C Alonso C Ortega AlonsoK28

👓
Learning Nest JS
View GitHub Profile
@AlonsoK28
AlonsoK28 / action.js
Created December 2, 2023 01:12
ngRx | modify state of nested object-array
on(setMenuChildrenOpen, (state, { parentId, childrenId }) => {
const result = state.map(parent => {
if (parent.subAppId === parentId) {
if (parent.children && parent.children?.length) {
const chilResult = parent.children.map(child => {
if (child.subAppId === childrenId) {
return {
...child,
isAlreadyOpen: true
}
@AlonsoK28
AlonsoK28 / search-into-object-array-by-id-relation.js
Last active January 10, 2023 01:43
search into object array using an id as relation
const example = [
{
name: 'Miles Toms',
age: 33,
city: 1,
office: 1,
job: 1,
lenguage: 1
},
{
@AlonsoK28
AlonsoK28 / remove-array-items-from-another-1.js
Last active December 7, 2021 03:54
remove first-class object array items from another array
// just copy and paste into your console and go on
const example = [
{
name: 'Miles Toms',
age: 33,
city: 'Brazil'
},
{
name: 'Jhones Miller',
@AlonsoK28
AlonsoK28 / fecth-api-iterate.js
Last active July 7, 2023 06:40
Iterate over Fetch API
const myData = [
{id:1, name:'data1'}, {id: 2, name: 'data2'}, {id:3, name: 'data3'}
];
async function mapJSFunc(currentValue) {
const url = 'https://api.github.com/?callback=foo'
return fetch(url)
.then(data => {
if (data.status === 200) {
return data;