diff options
Diffstat (limited to 'node_modules/react-dom/lib/adler32.js')
-rw-r--r-- | node_modules/react-dom/lib/adler32.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/node_modules/react-dom/lib/adler32.js b/node_modules/react-dom/lib/adler32.js new file mode 100644 index 000000000..e153adcb3 --- /dev/null +++ b/node_modules/react-dom/lib/adler32.js @@ -0,0 +1,43 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +var MOD = 65521; + +// adler32 is not cryptographically strong, and is only used to sanity check that +// markup generated on the server matches the markup generated on the client. +// This implementation (a modified version of the SheetJS version) has been optimized +// for our use case, at the expense of conforming to the adler32 specification +// for non-ascii inputs. +function adler32(data) { + var a = 1; + var b = 0; + var i = 0; + var l = data.length; + var m = l & ~0x3; + while (i < m) { + var n = Math.min(i + 4096, m); + for (; i < n; i += 4) { + b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3)); + } + a %= MOD; + b %= MOD; + } + for (; i < l; i++) { + b += a += data.charCodeAt(i); + } + a %= MOD; + b %= MOD; + return a | b << 16; +} + +module.exports = adler32;
\ No newline at end of file |