s101-lodash 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "s101-lodash",
3
+ "version": "1.0.0",
4
+ "description": "This is a real-world practical project like lodash.",
5
+ "main": "./src/index.js",
6
+ "scripts": {
7
+ "test": "jest"
8
+ },
9
+ "bin": {
10
+ "s101-lodash": "./src/index.js"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "type": "module",
16
+ "devDependencies": {
17
+ "jest": "^30.2.0"
18
+ }
19
+ }
package/src/index.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { chunk } = require("./utils/array");
4
+
5
+ module.exports = {
6
+ chunk
7
+ }
@@ -0,0 +1,12 @@
1
+ function chunk (array, size){
2
+ const result = [];
3
+
4
+ for (let i = 0; i< array.length; i+= size) {
5
+ result.push(array.slice(i, i+ size))
6
+ }
7
+ return result
8
+ }
9
+
10
+ module.exports = {
11
+ chunk
12
+ }
package/test/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Lodash-like NPM Package
2
+
3
+ ## Description
4
+ A lightweight utility library providing a collection of helpful functions for common programming tasks. This package offers functional programming utilities similar to Lodash, designed to simplify data manipulation, array operations, and object transformations.
5
+
6
+ ## Installation
7
+ ```bash
8
+ npm install lodash-like
9
+ ```
10
+
11
+ ## Usage Examples
12
+ ```javascript
13
+ const _ = require('lodash-like');
14
+
15
+ // Array operations
16
+ const {chunk} = require('lodash-like')
17
+ const numbers = [1, 2, 3, 4, 5];
18
+ const size = 2;
19
+ console.log(chunk(numbers, size)); // output:[[1,2],[3,4],[5]]
20
+
21
+ // Object operations
22
+ const user = { name: 'John', age: 30 };
23
+ const clone = _.clone(user);
24
+
25
+ // Collection utilities
26
+ const unique = _.uniq([1, 2, 2, 3, 3, 4]);
27
+ ```
28
+
29
+ ## Contributing
30
+ We welcome contributions! Please follow these guidelines:
31
+
32
+ 1. Fork the repository
33
+ 2. Create a feature branch: `git checkout -b feature/your-feature`
34
+ 3. Write tests for new functionality
35
+ 4. Commit with clear messages: `git commit -m 'Add feature description'`
36
+ 5. Push to your branch and submit a pull request
37
+ 6. Ensure all tests pass before submitting
38
+
39
+ ## License
40
+ MIT
41
+
42
+ # Lodash Project
@@ -0,0 +1,6 @@
1
+ const {chunk} = require("../src/utils/array.js")
2
+
3
+ test("chunk splits an array into smaller chunks", () => {
4
+ const array = [1,2,3,4,5];
5
+ expect(chunk(array, 2)).toEqual([[1,2],[3,4],[5]]);
6
+ })