Skip to content

JSlice is a Golang package that provides a set of methods to manipulate arrays which are built-in functions in JavaScript.

Notifications You must be signed in to change notification settings

anilsenay/jslice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSlice

Swagno

JSlice is a Golang package that provides a set of methods to manipulate arrays which are built-in functions in JavaScript.

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
go get github.com/anilsenay/jslice
  1. Import jslice
import "github.com/anilsenay/jslice"
  1. Use jslice methods
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.

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.

About

JSlice is a Golang package that provides a set of methods to manipulate arrays which are built-in functions in JavaScript.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages