Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anilsenay/jslice
JSlice is a Golang package that provides a set of methods to manipulate arrays which are built-in functions in JavaScript.
https://github.com/anilsenay/jslice
array function go golang javascript operations slice
Last synced: 15 days ago
JSON representation
JSlice is a Golang package that provides a set of methods to manipulate arrays which are built-in functions in JavaScript.
- Host: GitHub
- URL: https://github.com/anilsenay/jslice
- Owner: anilsenay
- Created: 2023-01-03T17:55:31.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-03T20:48:55.000Z (about 2 years ago)
- Last Synced: 2024-10-12T07:39:26.990Z (3 months ago)
- Topics: array, function, go, golang, javascript, operations, slice
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSlice
JSlice is a Golang package that provides a set of methods to manipulate arrays which are [built-in functions in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
## About the Project
I implemented this package as hobby project. I personally do not use external package for array manipulation. I prefer to implement them with for loop etc. when necessary. But if you are looking for a package that provides array manipulation methods, this package may help you.
## Getting started
1. Get jslice package in your project
```sh
go get github.com/anilsenay/jslice
```2. Import jslice
```go
import "github.com/anilsenay/jslice"
```3. Use jslice methods
```go
slice := jslice.Of(1, 2, 3, 4, 5)
filteredSlice = slice.Filter(func(i int) bool {return i > 3}) // [4,5]
filteredSlice = filteredSlice.Take(1) // [4]
```Chaning methods is also possible.
```go
intSlice := []int{1, 2, 3, 4, 5}
slice = jslice.From(intSlice).Filter(func(i int) bool {
return i > 3
}).Map(func(i int) int {
return i * 2
})fmt.Println(slice) // [8,10]
```## Methods
| Function | JavaScript | JSlice |
| ---------------- | ---------- | ------ |
| at() | ✅ | ✅ |
| concat() | ✅ | ✅ |
| copyWithin() | ✅ | ❌ |
| entries() | ✅ | ❌ |
| every() | ✅ | ✅ |
| fill() | ✅ | ❌ |
| filter() | ✅ | ✅ |
| find() | ✅ | ✅ |
| findIndex() | ✅ | ✅ |
| findLast() | ✅ | ✅ |
| findLastIndex() | ✅ | ✅ |
| flat() | ✅ | ❌ |
| flatMap() | ✅ | ❌ |
| forEach() | ✅ | ✅ |
| group() | ✅ | ❌ |
| groupToMap() | ✅ | ❌ |
| includes() | ✅ | ✅ |
| indexOf() | ✅ | ✅ |
| join() | ✅ | ✅ |
| keys() | ✅ | ✅ |
| lastIndexOf() | ✅ | ✅ |
| map() | ✅ | ✅ |
| pop() | ✅ | ✅ |
| push() | ✅ | ✅ |
| reduce() | ✅ | ❌ |
| reduceRight() | ✅ | ❌ |
| reverse() | ✅ | ✅ |
| shift() | ✅ | ✅ |
| slice() | ✅ | ✅ |
| some() | ✅ | ✅ |
| sort() | ✅ | ✅ |
| splice() | ✅ | ❌ |
| toLocaleString() | ✅ | ❌ |
| toString() | ✅ | ✅ |
| unshift() | ✅ | ✅ |
| values() | ✅ | ✅ |# Contribution
I am welcome to any contribution. Missing methods can be implemented. And also, you can improve the existing methods. Please feel free to open an issue or pull request.