https://github.com/zahidul-islam/ts-fun
Implementing lodash library in typescript for fun :-)
https://github.com/zahidul-islam/ts-fun
chai fun functional-programming lodash mocha typescript
Last synced: 4 months ago
JSON representation
Implementing lodash library in typescript for fun :-)
- Host: GitHub
- URL: https://github.com/zahidul-islam/ts-fun
- Owner: Zahidul-Islam
- License: mit
- Created: 2017-09-02T19:05:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-03T04:26:39.000Z (almost 8 years ago)
- Last Synced: 2024-12-29T04:53:20.080Z (6 months ago)
- Topics: chai, fun, functional-programming, lodash, mocha, typescript
- Language: TypeScript
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ts-fun
I have implements some functions from **lodash** library in typescript as a part of learning and understanding typescript language.# Build
```
npm run build
```# Running tests
```
npm test
```# Linting
```
npm run lint
```# Installation
```git clone https://github.com/Zahidul-Islam/ts-fun.git```# Usage
```
import * as _ from './path-to-ts-fun'
```### _.add(num1, num2)
```
_.add(6, 4);
// => 10
```### _.assign(...objects)
```
const foo = { a: 'a property' }
const bar = { b: 4, c: 'an other property' }_.assign({ a: 'an old property' }, foo, bar)
// => { a: 'a property', b: 4, c: 'an other property' }
```### _.chunk(array, size)
```
_.chunk(['a', 'b', 'c', 'd'], 2)
\\ => [['a', 'b'], ['c', 'd']]
```### _.compact(array)
```
_.compact([0, 1, false, 2, '', 3, undefined])
\\ => [1, 2, 3]
```### _.map()
```
let square = n => return n * n;_.map([4, 8], square);
// => [16, 64]
```### _.flatMap(array, func)
```
let duplicate = n => [n, n];_.flatMap([1, 2], duplicate);
// => [1, 1, 2, 2]
```### _.flatten(array)
```
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5]
```### _.flattenDeep(array)
```
_.flattenDeep([1, [2, [3, [4]], 5]]);
// => [1, 2, 3, 4, 5]
```### _.head(array)
```
_.head([1, 2, 3]);
// => 1
```### _.tail(array)
```
_.head([1, 2, 3]);
// => [2, 3]
```### _.sortedUniq(array)
```
_.sortedUniq([1, 1, 2]);
// => [1, 2]
```### _.time(num, func)
```
_.times(3, String);
// => ['0', '1', '2']
```
# LicenseThis project is licensed under the MIT License
# Acknowledgments
This project is inspired by awesome **lodash** library