function clamp(val, length) {
                val = (val | 0) || 0;

                if (val < 0) {
                    return Math.max(val + length, 0);
                }

                return Math.min(val, length);
            }
ArrayBuffer slice polyfill.

@see https://github.com/ttaubert/node-arraybuffer-slice