Badger...:Chain(3pm)

πŸ“¦
version 0.16 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute

πŸ’– Badger::Codec::Chain β€” bestie edition πŸ’–

okay so this is Badger::Codec::Chain, from the User Contributed Perl Documentation, living in section 3pm of your friendly neighbourhood man pages. she's a lil module that lets you stack codecs on top of each other like it's a fit check. ✨


✨ NAME ✨

Badger::Codec::Chain β€” encode/decode data using multiple codecs πŸ¦‹


✨ SYNOPSIS ✨

use Badger::Codec::Chain;

# compact form
my $codec = Badger::Codec::Chain->new('storable+base64');

# explicit form
my $codec = Badger::Codec::Chain->new('storable', 'base64');

# encode/decode data using codec chain
my $enc   = $codec->encode({ pi => 3.14, e => 2.718 });
my $dec   = $codec->decode($encoded);

✨ DESCRIPTION ✨

so basically πŸ’… this module is a subclass of Badger::Codec, and what it does is chain together any number of other codec modules. that's it. that's the whole vibe. one codec? cute. ten codecs? iconic. she stacks them. periodt. πŸ‘‘


✨ METHODS ✨

πŸŽ€ new(@codecs)

constructor method, bestie β€” she makes you a brand new codec chain ✨. the codecs can be specified by name or as references to Badger::Codec objects. whatever you're feeling, honestly.

# by name
my $codec = Badger::Codec::Chain->new('storable', 'base64');

# by object reference
my $codec = Badger::Codec::Chain->new(
    Badger::Codec->codec('storable'),
    Badger::Codec->codec('base64'),
);

you can also use the compact form where multiple codec names are separated by "+". yes the plus sign. she's doing math but make it codecs. 🧚

# compact form
my $codec = Badger::Codec::Chain->new('storable+base64');

πŸŽ€ encode($data)

encodes the data referenced by the first argument using all the codecs in the chain. every single one. no skips. 🌈

$encoded = $codec->encode($data);

πŸŽ€ decode($html)

decodes the encoded data passed as the first argument using all the codecs in the chain in reverse order. yes reverse. she's retracing her steps, main character energy. πŸ’«

$decoded = $codec->decode($encoded);

πŸŽ€ encoder()

returns a reference to a subroutine which performs the encoding operation. like, here's a lil function you can hold in your hand. 🫢

πŸŽ€ decoder()

returns a reference to a subroutine which performs the decoding operation. same energy, opposite direction. πŸ¦‹


✨ INTERNAL METHODS ✨

πŸ’… coder(@coders)

internal method to construct an encoder or decoder subroutine for a codec chain. that's it, that's the tea β€” it's internal, you're not meant to be here, but we love a peek behind the curtain. πŸ™ˆ


✨ AUTHOR ✨

Andy Wardley <http://wardley.org/> β€” king behaviour tbh πŸ‘‘


Copyright (C) 2005-2009 Andy Wardley. All rights reserved.


✨ SEE ALSO ✨

  • Badger::Codecs
  • Badger::Codec

go read those too bestie, iykyk πŸ’–


and that's the whole page!! no cap. this beauty shipped as perl v5.36.0, dated 2023-08-28. slay, stay safe, and hydrate before you chain too many codecs πŸ“πŸ’œ
πŸ“¦ where this page comes from