File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,22 @@ export class Base {
9696 Object . assign ( clone , this ) ;
9797 return clone ;
9898 }
99+
100+ /**
101+ * Get a new instance of this class.
102+ * Arguments to create() will be passed to constructor.
103+ *
104+ * @return {Object } The new object.
105+ *
106+ * @static
107+ *
108+ * @example
109+ *
110+ * var instance = MyType.create();
111+ */
112+ static create ( ...args ) {
113+ return new this ( ...args ) ;
114+ }
99115}
100116
101117/**
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ describe('algo-md5-test', () => {
4848 expect ( md5 . finalize ( ) . toString ( ) ) . toBe ( '7d017545e0268a6a12f2b507871d0429' ) ;
4949 } ) ;
5050
51+ test ( 'testCreate' , ( ) => {
52+ let i = 0 ;
53+ const md5 = C . algo . MD5 . create ( ) ;
54+ while ( i < 100 ) {
55+ md5 . update ( '12345678901234567890123456789012345678901234567890' ) ;
56+ i ++ ;
57+ }
58+ expect ( md5 . finalize ( ) . toString ( ) ) . toBe ( '7d017545e0268a6a12f2b507871d0429' ) ;
59+ } ) ;
60+
5161 test ( 'testInputIntegrity' , ( ) => {
5262 const message = new C . lib . WordArray ( [ 0x12345678 ] ) ;
5363 const expected = message . toString ( ) ;
You can’t perform that action at this time.
0 commit comments