Skip to content

Instantly share code, notes, and snippets.

View pporche87's full-sized avatar

Patrick Porche pporche87

View GitHub Profile
class Node {
constructor(element) {
this.element = element
this.next = null
}
}
class LinkedList {
constructor() {
this._length = 0
import chai, { expect } from 'chai'
import chaiChange from 'chai-change'
import { Node, LinkedList } from '../src/linkedListPatrick'
chai.use(chaiChange)
describe('LinkedList', () => {
let myLinkedList = new LinkedList()
myLinkedList.insert('apple')
export default class Stack {
constructor() {
//constructs the stack
this.dataStore = {}
this.top = 0
}
myPush(element) {
//pushes an element to the top of the stack
this.dataStore[this.top++] = element
import chai, { expect } from 'chai'
import chaiChange from 'chai-change'
import Stack from '../src/stack'
chai.use(chaiChange)
describe('Stack', () => {
'use strict'
it('exists', () => {
export default class Queues {
constructor() {
this.dataStore = []
this._oldestIndex = 1
this._newestIndex = 1
}
enqueue(element){
this.dataStore[this._newestIndex] = element
this._newestIndex++
import chai, { expect } from 'chai'
import chaiChange from 'chai-change'
import Queues from '../src/queues'
chai.use(chaiChange)
describe('Queues', () => {
'use strict'
it('exists', () => {
class PriorityNode {
constructor(data, priority) {
this.data = data
this.priority = priority
}
}
class PriorityQueues {
constructor() {
this.dataStore = []
import chai, { expect } from 'chai'
import chaiChange from 'chai-change'
import { PriorityNode, PriorityQueues } from '../src/priorityQueues'
chai.use(chaiChange)
describe('PriorityQueues', () => {
'use strict'
it('exists', () => {

lodash-clone

Common JS Utility Functions [Lodash]

Context

This project will take you into the realm of real a JavaScript library used by thousands (maybe millions) of developers across the world. You’ll have to think like an open-source software developer and learn the benefits and constraints of such a role.

In addition, your code may be used by other developers to make their jobs easier. Hopefully this project helps you better understand how to contribute to the open source community so that you can be an active member throughout your career.

The questions that this project will raise are:

32 Common JS Utility Functions [Lodash]

Array

chunk

Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

Arguments

array (Array): The array to process. [size=1] (number): The length of each chunk