Code Monkey home page Code Monkey logo

slc's Introduction

slc GoDoc CI Coverage Status

A generics-based toolset for working with slices.

Advantages:

  • Simple and clear API
  • Compatible with GO standard library

Yet to be done:

  • Improve performance. Some functions are not optimal and should not be used in critical paths.

Usage

Download the package

go get github.com/PlanitarInc/slc

Example

Playground link: https://go.dev/play/p/qu0t390uxt_p

package main

import (
	"fmt"

	"github.com/PlanitarInc/slc"
)

func main() {
	nums := []int{1, 2, 3, 4, 5}

	fmt.Println(slc.Includes(nums, 4)) // true
	fmt.Println(slc.Includes(nums, 9)) // false

	fmt.Println(slc.Every(nums, func(n int) bool {
		return n > 0
	})) // true
	fmt.Println(slc.Every(nums, func(n int) bool {
		return n%2 == 1
	})) // false

	type C struct {
		S string
		N int
	}

	objs := []C{
		{"a", 9},
		{"b", 8},
		{"c", 7},
	}
	fmt.Println(slc.Filter(objs, func(o C) bool {
		return o.N > 7
	})) // [{a 9}, {b 8}]
	fmt.Println(slc.FilterOut(objs, func(o C) bool {
		return o.S == "b"
	})) // [{a 9}, {c 7}]
}

Development

Feel free to modify the library and submit your changes. The main requirements are some reasonable asks for a library:

  • 100% test coverage
  • 100% documentation for public API (types, functions, constants)
  • readable code

slc's People

Contributors

dependabot[bot] avatar korya avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

korya rykpl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.