New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dois2/data-builder

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dois2/data-builder - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/Stack/index.d.ts

4

dist/index.d.ts

@@ -1,2 +0,2 @@

import { ArrayStack } from './Stack/ArrayStack';
export { ArrayStack };
import { ArrayStack, ObjectStack } from './Stack';
export { ArrayStack, ObjectStack };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayStack = void 0;
var ArrayStack_1 = require("./Stack/ArrayStack");
Object.defineProperty(exports, "ArrayStack", { enumerable: true, get: function () { return ArrayStack_1.ArrayStack; } });
exports.ObjectStack = exports.ArrayStack = void 0;
var Stack_1 = require("./Stack");
Object.defineProperty(exports, "ArrayStack", { enumerable: true, get: function () { return Stack_1.ArrayStack; } });
Object.defineProperty(exports, "ObjectStack", { enumerable: true, get: function () { return Stack_1.ObjectStack; } });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("./index");
var numberList = new index_1.ArrayStack();
var data_builder_1 = require("@dois2/data-builder");
var numberList = new data_builder_1.ArrayStack();
numberList.push(5);
numberList.push(8);
console.log(numberList.size);
console.log(numberList.items.toString());
numberList.push(9);
numberList.items = [];
numberList.pop();
console.log(numberList);
console.log("teste", numberList);
interface IArrayStack<T> {
items: T[];
push(data: T): void;
pop(): T | undefined;
peek(): T | undefined;
isEmpty(): boolean;
clear(): void;
size(): number;
}
export declare class ArrayStack<T> implements IArrayStack<T> {
items: T[];
private _items;
constructor();
push(data: T): void;
pop(): T | undefined;
peek(): T;
peek(): T | undefined;
isEmpty(): boolean;

@@ -11,0 +16,0 @@ clear(): void;

@@ -6,21 +6,23 @@ "use strict";

function ArrayStack() {
this.items = new Array();
this._items = new Array();
}
ArrayStack.prototype.push = function (data) {
this.items.push(data);
this._items.push(data);
};
ArrayStack.prototype.pop = function () {
return this.items.pop();
return this._items.pop();
};
ArrayStack.prototype.peek = function () {
return this.items[this.items.length - 1];
if (this.isEmpty())
return undefined;
return this._items[this._items.length - 1];
};
ArrayStack.prototype.isEmpty = function () {
return this.items.length === 0;
return this._items.length === 0;
};
ArrayStack.prototype.clear = function () {
this.items = new Array();
this._items = new Array();
};
ArrayStack.prototype.size = function () {
return this.items.length;
return this._items.length;
};

@@ -27,0 +29,0 @@ return ArrayStack;

@@ -1,4 +0,2 @@

import {ArrayStack} from './Stack/ArrayStack';
export { ArrayStack };
import { ArrayStack, ObjectStack} from './Stack';
export { ArrayStack, ObjectStack };
{
"name": "@dois2/data-builder",
"version": "1.0.0",
"version": "1.0.1",
"description": "Data structure ready to use",

@@ -21,3 +21,6 @@ "main": "dist/index.js",

},
"homepage": "https://github.com/Dois2/data-builder#readme"
"homepage": "https://github.com/Dois2/data-builder#readme",
"dependencies": {
}
}

@@ -7,8 +7,8 @@ import { ArrayStack } from './index'

numberList.push(8);
numberList.push(9);
console.log(numberList.size);
console.log(numberList.items.toString());
numberList.pop();
console.log(numberList);
console.log(`teste`, numberList);
interface IArrayStack<T>{
items: T[]
push(data: T) : void;
pop(): T| undefined;
peek(): T | undefined;
isEmpty(): boolean;
clear(): void;
size(): number;
}
export class ArrayStack<T> implements IArrayStack<T>{
public items;
private _items: Array<T> ;
constructor(){
this.items = new Array<T>();
this._items = new Array<T>();
}
public push(data: T) {
this.items.push(data);
push(data: T) {
this._items.push(data);
}
public pop(): T | undefined {
return this.items.pop();
pop(){
return this._items.pop();
}
public peek(){
return this.items[this.items.length - 1];
peek() {
if(this.isEmpty()) return undefined;
return this._items[this._items.length - 1];
}
public isEmpty(): boolean {
return this.items.length === 0;
isEmpty(){
return this._items.length === 0;
}
public clear(): void {
this.items = new Array<T>();
clear(){
this._items = new Array<T>();
}
public size(): number {
return this.items.length;
size(){
return this._items.length;
}
}
interface IObjectStack<T> {
items: IItemsObject<T>;
count: number;
push(data: T): void;
size(): number;
isEmpty(): boolean;
pop(): T | undefined;
peek(): T | undefined;
clear(): void;
toString(): string;
}

@@ -11,46 +16,46 @@

export class ObjectStack<T> implements IObjectStack<T> {
public items;
public count;
private _items;
private _count;
constructor() {
this.items = {} as IItemsObject<T>;
this.count = 0;
this._items = {} as IItemsObject<T>;
this._count = 0;
}
public push(data: T): void {
this.items[this.count] = data;
this.count++;
push(data: T) {
this._items[this._count] = data;
this._count++;
}
public size() : number {
return this.count;
size(){
return this._count;
}
public isEmpty(): boolean{
return this.count === 0;
isEmpty(){
return this._count === 0;
}
public pop(): T | undefined {
pop(){
if(this.isEmpty()) return undefined;
this.count--;
const result = this.items[this.count];
delete this.items[this.count];
this._count--;
const result = this._items[this._count];
delete this._items[this._count];
return result;
}
public peek() : T | undefined {
peek(){
if(this.isEmpty()) return undefined;
return this.items[this.count -1]
return this._items[this._count -1]
}
public clear() {
this.items = {} as IItemsObject<T>;
this.count = 0;
clear() {
this._items = {} as IItemsObject<T>;
this._count = 0;
}
public toString(): string{
toString(){
if(this.isEmpty()) return '';
let objToString = `${this.items[0]}`
for (let i = 1; i < this.count; i++) {
objToString = `${objToString},${this.items[i]}`
let objToString = `${this._items[0]}`
for (let i = 1; i < this._count; i++) {
objToString = `${objToString},${this._items[i]}`
}

@@ -57,0 +62,0 @@ return objToString;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc