File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,24 @@ String.prototype.hasPrefix = function (prefix) {
5656 const hasPrefix = this . indexOf ( prefix ) === 0 ;
5757 return hasPrefix ;
5858} ;
59+
60+ /**
61+ * @function hashCode
62+ * @memberof String
63+ * @description Return a hash code for a string.
64+ * @returns number
65+ */
66+ String . prototype . hashCode = function ( ) {
67+ let hash = 0 ;
68+ let i ;
69+ let chr ;
70+ if ( this . length === 0 ) return hash ;
71+ for ( i = 0 ; i < this . length ; i += 1 ) {
72+ chr = this . charCodeAt ( i ) ;
73+ // eslint-disable-next-line no-bitwise
74+ hash = ( ( hash << 5 ) - hash ) + chr ;
75+ // eslint-disable-next-line no-bitwise
76+ hash |= 0 ; // Convert to 32bit integer
77+ }
78+ return Math . abs ( hash ) ;
79+ } ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @djthorpe/js-framework" ,
3- "version" : " 0.0.41 " ,
3+ "version" : " 0.0.42 " ,
44 "description" : " Javascript Framework" ,
55 "main" : " dist/index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments