Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pyChaining

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyChaining

java stream style(high order, map reduce and method chaining) library for simplify the multiple map and filter operations

  • 0.0.2
  • PyPI
  • Socket score

Maintainers
1

Installation

pip install xethhung/pyChaining

Usage

from pyChaining import Chains

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).list()
assert xx == [1, 2, 3, 4, 5, 6, 7]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).filter(lambda x: x % 2 == 1).list()
assert xx == [1, 3, 5, 7]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).filter(lambda x: x % 2 == 1).map(lambda x: x * 2).list()
assert xx == [2, 6, 10, 14]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).filter(lambda x: x % 2 == 1).map(lambda x: x * 2)
    .skip(1).list()
assert xx == [6, 10, 14]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).filter(lambda x: x % 2 == 1).map(lambda x: x * 2)
    .skip(2).list()
assert xx == [10, 14]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).filter(lambda x: x % 2 == 1).map(lambda x: x * 2)
    .first()
assert xx == 2

xx = Chains.of([1, 2, 3, 4, 5, 6, 7]).filter(lambda x: x % 2 == 1).map(lambda x: x * 2)
    .last()
assert xx == 14

xx = Chains.of([1, 2, 3, 4, 5, 6, 7])
    .skipUntil(lambda x: x == 2).list()
assert xx == [2, 3, 4, 5, 6, 7]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7])
    .stopBefore(lambda x: x == 5).list()
assert xx == [1, 2, 3, 4]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7])
    .stopAt(lambda x: x == 5).list()
assert xx == [1, 2, 3, 4, 5]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7])
    .stopAfter(lambda x: x == 5, 1).list()
assert xx == [1, 2, 3, 4, 5, 6]

xx = Chains.of([1, 2, 3, 4, 5, 6, 7])
    .flatMap(lambda x: [x, x]).list()
assert xx == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]

xx = Chains.of([[1, 2, 3], [4, 5], [6, 7]])
    .flatten().list()
assert xx == [1, 2, 3, 4, 5, 6, 7]

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc