src/zmlib.js
function find_subarray(haystack, needle) {
        var h=0, n;

        var start = Date.now();

        HAYSTACK:
        while (h !== -1) {
            h = haystack.indexOf( needle[0], h );
            if (h === -1) break HAYSTACK;

            for (n=1; n<needle.length; n++) {
                if (haystack[h + n] !== needle[n]) {
                    h++;
                    continue HAYSTACK;
                }
            }

            return h;
        }

        return -1;
    }
function find_subarray(haystack, needle) {
        var h=0, n;

        var start = Date.now();

        HAYSTACK:
        while (h !== -1) {
            h = haystack.indexOf( needle[0], h );
            if (h === -1) break HAYSTACK;

            for (n=1; n<needle.length; n++) {
                if (haystack[h + n] !== needle[n]) {
                    h++;
                    continue HAYSTACK;
                }
            }

            return h;
        }

        return -1;
    }
Like Array.prototype.indexOf, but searches for a subarray
rather than just a particular value.

@param {Array} haystack - The array to search, i.e., the bigger.

@param {Array} needle - The array whose values to find,
i.e., the smaller.

@returns {number} The position in “haystack” where “needle”
first appears—or, -1 if “needle” doesn’t appear anywhere
in “haystack”.