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

github.com/sddilora/decorator_pattern

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sddilora/decorator_pattern

  • v0.0.0-20231201124648-0a36071ffc13
  • Source
  • Go
  • Socket score

Version published
Created
Source

��#� �D�e�c�o�r�a�t�o�r� �P�a�t�t�e�r�n� � �T�h�e� �D�e�c�o�r�a�t�o�r� �d�e�s�i�g�n� �p�a�t�t�e�r�n� �i�s� �a� �s�t�r�u�c�t�u�r�a�l� �p�a�t�t�e�r�n� �t�h�a�t� �a�l�l�o�w�s� �y�o�u� �t�o� �d�y�n�a�m�i�c�a�l�l�y� �a�d�d� �n�e�w� �b�e�h�a�v�i�o�r�s� �o�r� �f�u�n�c�t�i�o�n�a�l�i�t�i�e�s� �t�o� �a�n� �o�b�j�e�c�t� �w�i�t�h�o�u�t� �m�o�d�i�f�y�i�n�g� �i�t�s� �e�x�i�s�t�i�n�g� �c�o�d�e�.� �I�t� �f�o�l�l�o�w�s� �t�h�e� �p�r�i�n�c�i�p�l�e� �o�f� �o�p�e�n�-�c�l�o�s�e�d� �d�e�s�i�g�n�,� �w�h�i�c�h� �m�e�a�n�s� �t�h�a�t� �y�o�u� �c�a�n� �e�x�t�e�n�d� �t�h�e� �f�u�n�c�t�i�o�n�a�l�i�t�y� �o�f� �a�n� �o�b�j�e�c�t� �w�i�t�h�o�u�t� �m�o�d�i�f�y�i�n�g� �i�t�s� �u�n�d�e�r�l�y�i�n�g� �i�m�p�l�e�m�e�n�t�a�t�i�o�n�.� � � � �I�n� �t�h�e� �c�o�n�t�e�x�t� �o�f� �G�o� �(�G�o�l�a�n�g�)�,� �t�h�e� �D�e�c�o�r�a�t�o�r� �p�a�t�t�e�r�n� �c�a�n� �b�e� �i�m�p�l�e�m�e�n�t�e�d� �u�s�i�n�g� �a� �c�o�m�b�i�n�a�t�i�o�n� �o�f� �i�n�t�e�r�f�a�c�e�s� �a�n�d� �c�o�m�p�o�s�i�t�i�o�n�.� �L�e�t�'�s� �b�r�e�a�k� �d�o�w�n� �t�h�e� �i�m�p�l�e�m�e�n�t�a�t�i�o�n� �s�t�e�p� �b�y� �s�t�e�p�:� � � � �1�.� �D�e�f�i�n�e� �t�h�e� �b�a�s�e� �i�n�t�e�r�f�a�c�e�:� �S�t�a�r�t� �b�y� �d�e�f�i�n�i�n�g� �a�n� �i�n�t�e�r�f�a�c�e� �t�h�a�t� �r�e�p�r�e�s�e�n�t�s� �t�h�e� �b�a�s�e� �f�u�n�c�t�i�o�n�a�l�i�t�y� �o�f� �t�h�e� �o�b�j�e�c�t� �y�o�u� �w�a�n�t� �t�o� �d�e�c�o�r�a�t�e�.� �T�h�i�s� �i�n�t�e�r�f�a�c�e� �s�h�o�u�l�d� �i�n�c�l�u�d�e� �t�h�e� �c�o�m�m�o�n� �m�e�t�h�o�d�s� �t�h�a�t� �a�l�l� �d�e�c�o�r�a�t�o�r�s� �a�n�d� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� �w�i�l�l� �i�m�p�l�e�m�e�n�t�.� � � � �2�.� �I�m�p�l�e�m�e�n�t� �t�h�e� �b�a�s�e� �o�b�j�e�c�t�:� �C�r�e�a�t�e� �a� �s�t�r�u�c�t� �t�h�a�t� �i�m�p�l�e�m�e�n�t�s� �t�h�e� �b�a�s�e� �i�n�t�e�r�f�a�c�e�.� �T�h�i�s� �s�t�r�u�c�t� �r�e�p�r�e�s�e�n�t�s� �t�h�e� �c�o�r�e� �f�u�n�c�t�i�o�n�a�l�i�t�y� �o�f� �t�h�e� �o�b�j�e�c�t� �t�h�a�t� �y�o�u� �w�a�n�t� �t�o� �d�e�c�o�r�a�t�e�.� � � � �3�.� �C�r�e�a�t�e� �t�h�e� �d�e�c�o�r�a�t�o�r� �i�n�t�e�r�f�a�c�e�:� �D�e�f�i�n�e� �a�n�o�t�h�e�r� �i�n�t�e�r�f�a�c�e� �t�h�a�t� �e�x�t�e�n�d�s� �t�h�e� �b�a�s�e� �i�n�t�e�r�f�a�c�e� �a�n�d� �i�n�c�l�u�d�e�s� �a�d�d�i�t�i�o�n�a�l� �m�e�t�h�o�d�s� �s�p�e�c�i�f�i�c� �t�o� �t�h�e� �d�e�c�o�r�a�t�o�r�s�.� �T�h�i�s� �i�n�t�e�r�f�a�c�e� �s�h�o�u�l�d� �a�l�s�o� �i�n�c�l�u�d�e� �a� �r�e�f�e�r�e�n�c�e� �t�o� �t�h�e� �b�a�s�e� �i�n�t�e�r�f�a�c�e�.� � � � �4�.� �I�m�p�l�e�m�e�n�t� �t�h�e� �d�e�c�o�r�a�t�o�r�s�:� �C�r�e�a�t�e� �s�t�r�u�c�t�s� �t�h�a�t� �i�m�p�l�e�m�e�n�t� �t�h�e� �d�e�c�o�r�a�t�o�r� �i�n�t�e�r�f�a�c�e�.� �E�a�c�h� �d�e�c�o�r�a�t�o�r� �s�t�r�u�c�t� �s�h�o�u�l�d� �h�a�v�e� �a� �f�i�e�l�d� �o�f� �t�h�e� �b�a�s�e� �i�n�t�e�r�f�a�c�e� �t�y�p�e� �t�o� �h�o�l�d� �a� �r�e�f�e�r�e�n�c�e� �t�o� �t�h�e� �o�b�j�e�c�t� �b�e�i�n�g� �d�e�c�o�r�a�t�e�d�.� �T�h�e� �d�e�c�o�r�a�t�o�r� �s�t�r�u�c�t� �s�h�o�u�l�d� �a�l�s�o� �i�m�p�l�e�m�e�n�t� �t�h�e� �m�e�t�h�o�d�s� �d�e�f�i�n�e�d� �i�n� �t�h�e� �d�e�c�o�r�a�t�o�r� �i�n�t�e�r�f�a�c�e�,� �a�d�d�i�n�g� �n�e�w� �b�e�h�a�v�i�o�r� �o�r� �m�o�d�i�f�y�i�n�g� �t�h�e� �e�x�i�s�t�i�n�g� �b�e�h�a�v�i�o�r� �a�s� �n�e�e�d�e�d�.� � � � �5�.� �D�e�c�o�r�a�t�e� �t�h�e� �b�a�s�e� �o�b�j�e�c�t�:� �I�n� �y�o�u�r� �c�o�d�e�,� �c�r�e�a�t�e� �a�n� �i�n�s�t�a�n�c�e� �o�f� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� �a�n�d� �t�h�e�n� �w�r�a�p� �i�t� �w�i�t�h� �o�n�e� �o�r� �m�o�r�e� �d�e�c�o�r�a�t�o�r�s�.� �E�a�c�h� �d�e�c�o�r�a�t�o�r� �w�r�a�p�s� �t�h�e� �p�r�e�v�i�o�u�s� �d�e�c�o�r�a�t�o�r� �o�r� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� �i�t�s�e�l�f�.� �T�h�i�s� �a�l�l�o�w�s� �y�o�u� �t�o� �s�t�a�c�k� �m�u�l�t�i�p�l�e� �d�e�c�o�r�a�t�o�r�s� �a�n�d� �d�y�n�a�m�i�c�a�l�l�y� �a�d�d� �n�e�w� �f�u�n�c�t�i�o�n�a�l�i�t�i�e�s� �t�o� �t�h�e� �o�b�j�e�c�t�.� � � � �H�e�r�e�'�s� �a� �s�i�m�p�l�i�f�i�e�d� �e�x�a�m�p�l�e� �i�n� �G�o� �t�o� �i�l�l�u�s�t�r�a�t�e� �t�h�e� �D�e�c�o�r�a�t�o�r� �p�a�t�t�e�r�n�:� � � � ��g�o� � �/�/� �S�t�e�p� �1�:� �D�e�f�i�n�e� �t�h�e� �b�a�s�e� �i�n�t�e�r�f�a�c�e� � �t�y�p�e� �C�o�m�p�o�n�e�n�t� �i�n�t�e�r�f�a�c�e� �{� � � � � � �O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� � �}� � � � �/�/� �S�t�e�p� �2�:� �I�m�p�l�e�m�e�n�t� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� � �t�y�p�e� �C�o�n�c�r�e�t�e�C�o�m�p�o�n�e�n�t� �s�t�r�u�c�t�{�}� � � � �f�u�n�c� �(�c� �*�C�o�n�c�r�e�t�e�C�o�m�p�o�n�e�n�t�)� �O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� �{� � � � � � �r�e�t�u�r�n� �"�B�a�s�e� �o�p�e�r�a�t�i�o�n�"� � �}� � � � �/�/� �S�t�e�p� �3�:� �C�r�e�a�t�e� �t�h�e� �d�e�c�o�r�a�t�o�r� �i�n�t�e�r�f�a�c�e� � �t�y�p�e� �D�e�c�o�r�a�t�o�r� �i�n�t�e�r�f�a�c�e� �{� � � � � � �C�o�m�p�o�n�e�n�t� � � � � � �A�d�d�i�t�i�o�n�a�l�O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� � �}� � � � �/�/� �S�t�e�p� �4�:� �I�m�p�l�e�m�e�n�t� �t�h�e� �d�e�c�o�r�a�t�o�r�s� � �t�y�p�e� �C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�A� �s�t�r�u�c�t� �{� � � � � � �c�o�m�p�o�n�e�n�t� �C�o�m�p�o�n�e�n�t� � �}� � � � �f�u�n�c� �(�d� �*�C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�A�)� �O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� �{� � � � � � �r�e�t�u�r�n� �d�.�c�o�m�p�o�n�e�n�t�.�O�p�e�r�a�t�i�o�n�(�)� �+� �"� �+� �D�e�c�o�r�a�t�o�r� �A�"� � �}� � � � �f�u�n�c� �(�d� �*�C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�A�)� �A�d�d�i�t�i�o�n�a�l�O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� �{� � � � � � �r�e�t�u�r�n� �"�A�d�d�i�t�i�o�n�a�l� �o�p�e�r�a�t�i�o�n� �A�"� � �}� � � � �t�y�p�e� �C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�B� �s�t�r�u�c�t� �{� � � � � � �c�o�m�p�o�n�e�n�t� �C�o�m�p�o�n�e�n�t� � �}� � � � �f�u�n�c� �(�d� �*�C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�B�)� �O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� �{� � � � � � �r�e�t�u�r�n� �d�.�c�o�m�p�o�n�e�n�t�.�O�p�e�r�a�t�i�o�n�(�)� �+� �"� �+� �D�e�c�o�r�a�t�o�r� �B�"� � �}� � � � �f�u�n�c� �(�d� �*�C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�B�)� �A�d�d�i�t�i�o�n�a�l�O�p�e�r�a�t�i�o�n�(�)� �s�t�r�i�n�g� �{� � � � � � �r�e�t�u�r�n� �"�A�d�d�i�t�i�o�n�a�l� �o�p�e�r�a�t�i�o�n� �B�"� � �}� � � � �/�/� �S�t�e�p� �5�:� �D�e�c�o�r�a�t�e� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� � �f�u�n�c� �m�a�i�n�(�)� �{� � � � � � �c�o�m�p�o�n�e�n�t� �:�=� �&�C�o�n�c�r�e�t�e�C�o�m�p�o�n�e�n�t�{�}� � � � � � �d�e�c�o�r�a�t�e�d�C�o�m�p�o�n�e�n�t� �:�=� �&�C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�A�{�c�o�m�p�o�n�e�n�t�:� �c�o�m�p�o�n�e�n�t�}� � � � � � �d�e�c�o�r�a�t�e�d�C�o�m�p�o�n�e�n�t� �=� �&�C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�B�{�c�o�m�p�o�n�e�n�t�:� �d�e�c�o�r�a�t�e�d�C�o�m�p�o�n�e�n�t�}� � � � � � � � �r�e�s�u�l�t� �:�=� �d�e�c�o�r�a�t�e�d�C�o�m�p�o�n�e�n�t�.�O�p�e�r�a�t�i�o�n�(�)� � � � � � �a�d�d�i�t�i�o�n�a�l�R�e�s�u�l�t� �:�=� �d�e�c�o�r�a�t�e�d�C�o�m�p�o�n�e�n�t�.�A�d�d�i�t�i�o�n�a�l�O�p�e�r�a�t�i�o�n�(�)� � � � � � � � �f�m�t�.�P�r�i�n�t�l�n�(�r�e�s�u�l�t�)� � � � � � � � � � � � �/�/� �O�u�t�p�u�t�:� �B�a�s�e� �o�p�e�r�a�t�i�o�n� �+� �D�e�c�o�r�a�t�o�r� �A� �+� �D�e�c�o�r�a�t�o�r� �B� � � � � � �f�m�t�.�P�r�i�n�t�l�n�(�a�d�d�i�t�i�o�n�a�l�R�e�s�u�l�t�)� � �/�/� �O�u�t�p�u�t�:� �A�d�d�i�t�i�o�n�a�l� �o�p�e�r�a�t�i�o�n� �B� � �}� � �� � � � �I�n� �t�h�i�s� �e�x�a�m�p�l�e�,� �w�e� �h�a�v�e� �a� �b�a�s�e� �i�n�t�e�r�f�a�c�e� ��C�o�m�p�o�n�e�n�t�� �t�h�a�t� �d�e�f�i�n�e�s� �t�h�e� ��O�p�e�r�a�t�i�o�n�(�)�� �m�e�t�h�o�d�.� �T�h�e� ��C�o�n�c�r�e�t�e�C�o�m�p�o�n�e�n�t�� �s�t�r�u�c�t� �i�m�p�l�e�m�e�n�t�s� �t�h�i�s� �i�n�t�e�r�f�a�c�e� �a�n�d� �r�e�p�r�e�s�e�n�t�s� �t�h�e� �b�a�s�e� �o�b�j�e�c�t�.� � � � �W�e� �t�h�e�n� �d�e�f�i�n�e� �t�h�e� ��D�e�c�o�r�a�t�o�r�� �i�n�t�e�r�f�a�c�e�,� �w�h�i�c�h� �e�x�t�e�n�d�s� �t�h�e� ��C�o�m�p�o�n�e�n�t�� �i�n�t�e�r�f�a�c�e� �a�n�d� �a�d�d�s� �t�h�e� ��A�d�d�i�t�i�o�n�a�l�O�p�e�r�a�t�i�o�n�(�)�� �m�e�t�h�o�d�.� � � � �N�e�x�t�,� �w�e� �i�m�p�l�e�m�e�n�t� �t�w�o� �d�e�c�o�r�a�t�o�r�s�:� ��C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�A�� �a�n�d� ��C�o�n�c�r�e�t�e�D�e�c�o�r�a�t�o�r�B��.� �E�a�c�h� �d�e�c�o�r�a�t�o�r� �w�r�a�p�s� �t�h�e� �p�r�e�v�i�o�u�s� �d�e�c�o�r�a�t�o�r� �o�r� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� �a�n�d� �a�d�d�s� �n�e�w� �b�e�h�a�v�i�o�r� �t�o� �t�h�e� ��O�p�e�r�a�t�i�o�n�(�)�� �m�e�t�h�o�d�.� �T�h�e�y� �a�l�s�o� �i�m�p�l�e�m�e�n�t� �t�h�e� ��A�d�d�i�t�i�o�n�a�l�O�p�e�r�a�t�i�o�n�(�)�� �m�e�t�h�o�d� �w�i�t�h� �t�h�e�i�r� �o�w�n� �s�p�e�c�i�f�i�c� �f�u�n�c�t�i�o�n�a�l�i�t�y�.� � � � �F�i�n�a�l�l�y�,� �i�n� �t�h�e� ��m�a�i�n�(�)�� �f�u�n�c�t�i�o�n�,� �w�e� �c�r�e�a�t�e� �a�n� �i�n�s�t�a�n�c�e� �o�f� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� �a�n�d� �w�r�a�p� �i�t� �w�i�t�h� �t�h�e� �d�e�c�o�r�a�t�o�r�s�.� �W�e� �c�a�n� �t�h�e�n� �c�a�l�l� �t�h�e� �m�e�t�h�o�d�s� �o�n� �t�h�e� �d�e�c�o�r�a�t�e�d� �o�b�j�e�c�t� �t�o� �s�e�e� �t�h�e� �c�o�m�b�i�n�e�d� �b�e�h�a�v�i�o�r�.� � � � �B�y� �u�s�i�n�g� �t�h�e� �D�e�c�o�r�a�t�o�r� �p�a�t�t�e�r�n�,� �w�e� �c�a�n� �e�a�s�i�l�y� �a�d�d� �o�r� �r�e�m�o�v�e� �d�e�c�o�r�a�t�o�r�s� �w�i�t�h�o�u�t� �m�o�d�i�f�y�i�n�g� �t�h�e� �b�a�s�e� �o�b�j�e�c�t� �o�r� �o�t�h�e�r� �d�e�c�o�r�a�t�o�r�s�.� �T�h�i�s� �a�l�l�o�w�s� �f�o�r� �f�l�e�x�i�b�l�e� �a�n�d� �d�y�n�a�m�i�c� �b�e�h�a�v�i�o�r� �m�o�d�i�f�i�c�a�t�i�o�n� �a�t� �r�u�n�t�i�m�e�.�T�h�e� �D�e�c�o�r�a�t�o�r� �d�e�s�i�g�n� �p�a�t�t�e�r�n� �i�s� �a� �s�t�r�u�c�t�u�r�a�l� �p�a�t�t�e�r�n� �t�h�a�t� �a�l�l�o�w�s� �y�o�u� �t�o� �d�y�n�a�m�i�c�a�l�l�y� �a�d�d� �n�e�w� �b�e�h�a�v�i�o�r�s� �o�r� �f�u�n�c�t�i�o�n�a�l�i�t�i�e�s� �t�o� �a�n� �o�b�j�e�c�t� �w�i�t�h�o�u�t� �m�o�d�i�f�y�i�n�g� �i�t�s� �e�x�i�s�t�i�n�g� �c�o�d�e�.� �I�t� �f�o�l�l�o�w�s� �t�h�e� �p�r�i�n�c�i�p�l�e� �o�f� �o�p�e�n�-�c�l�o�s�e�d� �d�e�s�i�g�n�,� �w�h�i�c�h� �m�e�a�n�s� �t�h�a�t� �y�o�u� �c�a�n� �e�x�t�e�n�d� �t�h�e� �f�u�n�c�t�i�o�n�a�l�i�t�y� �o�f� �a�n� �o�b�j�e�c�t� �w�i�t�h�o�u�t� �m�o�d�i�f�y�i�n�g� �i�t�s� �u�n�d�e�r�l�y�i�n�g� �i�m�p�l�e�m�e�n�t�a�t�i�o�n�.�

FAQs

Package last updated on 01 Dec 2023

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