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

auxin

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auxin - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

7

dist/arrayUtils.d.ts

@@ -18,2 +18,9 @@ export declare namespace arrayUtils {

function quickSort<T>(arr: T[]): T[];
function arrPush<T>(arr: T[], target: T): T[];
function arrUnshift<T>(arr: T[], target: T): T[];
function arrPop<T>(arr: T[]): T[];
function arrShift<T>(arr: T[]): T[];
function arrSlice<T>(arr: T[], start: number, end: number): T[];
function arrToUpperCase<T>(arr: T[]): T[];
function arrToLowerCase<T>(arr: T[]): T[];
}

@@ -63,4 +63,67 @@ "use strict";

arrayUtils.quickSort = quickSort;
function arrPush(arr, target) {
arr.push(target);
return arr;
}
arrayUtils.arrPush = arrPush;
function arrUnshift(arr, target) {
arr.unshift(target);
return arr;
}
arrayUtils.arrUnshift = arrUnshift;
function arrPop(arr) {
arr.pop();
return arr;
}
arrayUtils.arrPop = arrPop;
function arrShift(arr) {
arr.shift();
return arr;
}
arrayUtils.arrShift = arrShift;
function arrSlice(arr, start, end) {
arr.slice(start, end);
return arr;
}
arrayUtils.arrSlice = arrSlice;
function arrToUpperCase(arr) {
// Create a new array to store the uppercase elements
const upperCaseArray = [];
// Iterate through the original array and convert each element to uppercase
for (const element of arr) {
// Check if the element is a string
if (typeof element === 'string') {
// If it's a string, convert it to uppercase and push to the new array
upperCaseArray.push(element.toUpperCase());
}
else {
// If it's not a string, push it to the new array as is
upperCaseArray.push(element);
}
}
// Return the array with all elements converted to uppercase
return upperCaseArray;
}
arrayUtils.arrToUpperCase = arrToUpperCase;
function arrToLowerCase(arr) {
// Create a new array to store the lowercase elements
const lowerCaseArray = [];
// Iterate through the original array and convert each element to lowercase
for (const element of arr) {
// Check if the element is a string
if (typeof element === 'string') {
// If it's a string, convert it to lowercase and push to the new array
lowerCaseArray.push(element.toLowerCase());
}
else {
// If it's not a string, push it to the new array as is
lowerCaseArray.push(element);
}
}
// Return the array with all elements converted to lowercase
return lowerCaseArray;
}
arrayUtils.arrToLowerCase = arrToLowerCase;
// Add more array utility functions here as needed...
})(arrayUtils || (exports.arrayUtils = arrayUtils = {}));
//# sourceMappingURL=arrayUtils.js.map

174

docs/arrayutils.md

@@ -94,2 +94,174 @@ # Array Utility Functions Documentation

console.log(sortedArr); // Output: [1, 1, 2, 3, 4, 5, 5, 6, 9]
```
```
## `arrPush`
Appends an element to the end of an array.
### Parameters
- `arr`: The array to modify.
- `target`: The element to append to the array.
### Returns
The modified array with the element appended.
### Example
```typescript
import { arrPush } from 'auxin';
let arr = [1, 2, 3];
arr = arrPush(arr, 4);
console.log(arr); // Output: [1, 2, 3, 4]
```
## `arrUnshift`
Prepends an element to the beginning of an array.
### Parameters
- `arr`: The array to modify.
- `target`: The element to prepend to the array.
### Returns
The modified array with the element prepended.
### Example
```typescript
import { arrUnshift } from 'auxin';
let arr = [2, 3, 4];
arr = arrUnshift(arr, 1);
console.log(arr); // Output: [1, 2, 3, 4]
```
## `arrPop`
Removes the last element from an array.
### Parameters
- `arr`: The array to modify.
### Returns
The modified array with the last element removed.
### Example
```typescript
import { arrPop } from 'auxin';
let arr = [1, 2, 3];
arr = arrPop(arr);
console.log(arr); // Output: [1, 2]
```
## `arrShift`
Removes the first element from an array.
### Parameters
- `arr`: The array to modify.
### Returns
The modified array with the first element removed.
### Example
```typescript
import { arrShift } from 'auxin';
let arr = [1, 2, 3];
arr = arrShift(arr);
console.log(arr); // Output: [2, 3]
```
## `arrSlice`
Extracts a section of an array and returns a new array.
### Parameters
- `arr`: The array to slice.
- `start`: The start index.
- `end`: The end index (exclusive).
### Returns
A new array containing the sliced elements.
### Example
```typescript
import { arrSlice } from 'auxin';
const arr = [1, 2, 3, 4, 5];
const slicedArr = arrSlice(arr, 1, 3);
console.log(slicedArr); // Output: [2, 3]
```
## `arrToUpperCase`
Converts all string elements of an array to uppercase.
### Parameters
- `arr`: The array to modify.
### Returns
A new array with all string elements converted to uppercase.
### Example
```typescript
import { arrToUpperCase } from 'auxin';
const arr = ['hello', 'world'];
const upperCaseArr = arrToUpperCase(arr);
console.log(upperCaseArr); // Output: ['HELLO', 'WORLD']
```
## `arrToLowerCase`
Converts all string elements of an array to lowercase.
### Parameters
- `arr`: The array to modify.
### Returns
A new array with all string elements converted to lowercase.
### Example
```typescript
import { arrToLowerCase } from 'auxin';
const arr = ['HELLO', 'WORLD'];
const lowerCaseArr = arrToLowerCase(arr);
console.log(lowerCaseArr); // Output: ['hello', 'world']
```
## `arrayUtils`
Exports all array utility functions.
### Example
```typescript
import * as arrayUtils from 'auxin';
const arr = [1, 2, 3, 4, 5];
const filteredArr = arrayUtils.filterArray(arr, num => num % 2 === 0);
console.log(filteredArr); // Output: [2, 4]
```

2

package.json
{
"name": "auxin",
"version": "1.9.0",
"version": "1.10.0",
"description": "Auxin is a powerful Node.js utility toolkit that simplifies common tasks, boosting your development productivity.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -62,3 +62,71 @@ export module arrayUtils {

export function arrPush<T>(arr: T[], target: T): T[] {
arr.push(target);
return arr;
}
export function arrUnshift<T>(arr: T[], target: T): T[] {
arr.unshift(target);
return arr;
}
export function arrPop<T>(arr: T[]): T[] {
arr.pop();
return arr;
}
export function arrShift<T>(arr: T[]): T[] {
arr.shift();
return arr;
}
export function arrSlice<T>(arr: T[], start: number, end: number): T[] {
arr.slice(start, end);
return arr;
}
export function arrToUpperCase<T>(arr: T[]): T[] {
// Create a new array to store the uppercase elements
const upperCaseArray: T[] = [];
// Iterate through the original array and convert each element to uppercase
for (const element of arr) {
// Check if the element is a string
if (typeof element === 'string') {
// If it's a string, convert it to uppercase and push to the new array
upperCaseArray.push(element.toUpperCase() as unknown as T);
} else {
// If it's not a string, push it to the new array as is
upperCaseArray.push(element);
}
}
// Return the array with all elements converted to uppercase
return upperCaseArray;
}
export function arrToLowerCase<T>(arr: T[]): T[] {
// Create a new array to store the lowercase elements
const lowerCaseArray: T[] = [];
// Iterate through the original array and convert each element to lowercase
for (const element of arr) {
// Check if the element is a string
if (typeof element === 'string') {
// If it's a string, convert it to lowercase and push to the new array
lowerCaseArray.push(element.toLowerCase() as unknown as T);
} else {
// If it's not a string, push it to the new array as is
lowerCaseArray.push(element);
}
}
// Return the array with all elements converted to lowercase
return lowerCaseArray;
}
// Add more array utility functions here as needed...
}
const { arrayUtils } = require('../dist/arrayUtils'); // Import the array utility functions to be tested
const arr = ['a', 'b', 'c', 'd', 'e'];
const index = arrayUtils.binarySearch(arr, 'c');
console.log(index); // Output: 2
const arrr = [3, 1, 4, 1, 5, 9, 2, 6, 5];
const sortedArr = arrayUtils.quickSort(arrr);
console.log(sortedArr); // Output: [1, 1, 2, 3, 4, 5, 5, 6, 9]
const pushedArray = arrayUtils.arrPush(arr, 3);
console.log(pushedArray);
const unshiftedArr = arrayUtils.arrUnshift(arrr, 3)
console.log(unshiftedArr);
const arre = [3, 1, 4, 1, 5, 9, 2, 6, 5];
const poppedArr = arrayUtils.arrPop(arre)
console.log(poppedArr);

Sorry, the diff of this file is not supported yet

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