<commit_before>/* eslint-env browser, es6, amd, commonjs */

/*
 * Scrollmarks
 * Copyright (c) 2017 <NAME>
 * Licensed under the MIT License.
 * https://github.com/jamonserrano/scrollmarks
 */

// store for scrollmarks
const scrollMarks = window.Map ? new Map() : createMockMap();
// index of scrollmarks
let index = 0;
// queue for triggered marks
let queue = [];

// central clock, 0 when stopped, arbitrary number (the return value of requestAnimationFrame) when running
let clock = 0;

// configuration
const config = {
	// throttle for scroll events (configurable)
	scrollThrottle: 10,
	// throttle for resize events (configurable)
	resizeThrottle: 30,
	// maximum allowed timeout (configurable, 0 to trigger instantly)
	idleTimeout: 100
};

// document was scrolled
let scrolled = false;
// frame counter for scroll events
let scrollTick = 1;
// previous scroll position;
let previousScroll = 0;
// scroll direction
let scrollDirection;

// document was resized
let resized = false;
// frame counter for resize events
let resizeTick = 1;
// documentElement cached
const documentElement = document.documentElement;
// previous document height
let previousHeight = documentElement.scrollHeight;

// browser supports idle callback
const hasIdleCallback = Boolean(window.requestIdleCallback);

// event listener properties (false by default)
let listenerProperties = false;
// set passive listener if available
window.addEventListener("test", null, {
	get passive() {
		listenerProperties = {
			passive: true
		}
	}
});

/**
 * Add a new scrollmark
 * @public
 * @param {Object} mark
 * @param {HTMLElement} mark.element
 * @param {Function} mark.callback
 * @param {(number|string|function)} [mark.offset]
 * @param {('up'|'down')} [mark.direction]
 * @param {boolean} [mark.once]
 * @param {boolean} [mark.debug]
 * @return {number} key
 */
function add (mark) {
	const { element, callback, offset, direction, once, debug } = mark;

	if (!(element instanceof HTMLElement)) {
		throw new TypeError(errorMessage(false, 'element', 'an HTML Element', element));
	}

	if (!isFunction(callback)) {
		throw new TypeError(errorMessage(false, 'callback', 'a function', callback));
	}

	if (isUndefined(offset)) {
		// default
		mark.computedOffset = 0;
	} else if (isNumber(offset) || isFunction(offset)) {
		mark.computedOffset = offset;
	} else if (isString(offset) && offset.slice(-1) === '%') {
		// generate function from percentage (viewport size can change)
		mark.computedOffset = () => window.innerHeight * parseInt(offset) / 100;
	} else if (isString(offset) && offset.slice(-2) === 'px') {
		mark.computedOffset = parseInt(offset);
	} else {
		throw new TypeError(errorMessage('Optional', 'offset', 'a number, px, %, or a function', offset));
	}

	if (!isUndefined(direction) && direction !== 'up' && direction !== 'down') {
		throw new TypeError(errorMessage('Optional', 'direction', `'up' or 'down'`, direction));
	}

	if (!(isUndefined(once) || isBoolean(once))) {
		throw new TypeError(errorMessage('Optional', 'once', 'boolean', once));<commit_msg>Use empty string instead of false<commit_after>/* eslint-env browser, es6, amd, commonjs */

/*
 * Scrollmarks
 * Copyright (c) 2017 <NAME>
 * Licensed under the MIT License.
 * https://github.com/jamonserrano/scrollmarks
 */

// store for scrollmarks
const scrollMarks = window.Map ? new Map() : createMockMap();
// index of scrollmarks
let index = 0;
// queue for triggered marks
let queue = [];

// central clock, 0 when stopped, arbitrary number (the return value of requestAnimationFrame) when running
let clock = 0;

// configuration
const config = {
	// throttle for scroll events (configurable)
	scrollThrottle: 10,
	// throttle for resize events (configurable)
	resizeThrottle: 30,
	// maximum allowed timeout (configurable, 0 to trigger instantly)
	idleTimeout: 100
};

// document was scrolled
let scrolled = false;
// frame counter for scroll events
let scrollTick = 1;
// previous scroll position;
let previousScroll = 0;
// scroll direction
let scrollDirection;

// document was resized
let resized = false;
// frame counter for resize events
let resizeTick = 1;
// documentElement cached
const documentElement = document.documentElement;
// previous document height
let previousHeight = documentElement.scrollHeight;

// browser supports idle callback
const hasIdleCallback = Boolean(window.requestIdleCallback);

// event listener properties (false by default)
let listenerProperties = false;
// set passive listener if available
window.addEventListener("test", null, {
	get passive() {
		listenerProperties = {
			passive: true
		}
	}
});

/**
 * Add a new scrollmark
 * @public
 * @param {Object} mark
 * @param {HTMLElement} mark.element
 * @param {Function} mark.callback
 * @param {(number|string|function)} [mark.offset]
 * @param {('up'|'down')} [mark.direction]
 * @param {boolean} [mark.once]
 * @param {boolean} [mark.debug]
 * @return {number} key
 */
function add (mark) {
	const { element, callback, offset, direction, once, debug } = mark;

	if (!(element instanceof HTMLElement)) {
		throw new TypeError(errorMessage('', 'element', 'an HTML Element', element));
	}

	if (!isFunction(callback)) {
		throw new TypeError(errorMessage('', 'callback', 'a function', callback));
	}

	if (isUndefined(offset)) {
		// default
		mark.computedOffset = 0;
	} else if (isNumber(offset) || isFunction(offset)) {
		mark.computedOffset = offset;
	} else if (isString(offset) && offset.slice(-1) === '%') {
		// generate function from percentage (viewport size can change)
		mark.computedOffset = () => window.innerHeight * parseInt(offset) / 100;
	} else if (isString(offset) && offset.slice(-2) === 'px') {
		mark.computedOffset = parseInt(offset);
	} else {
		throw new TypeError(errorMessage('Optional', 'offset', 'a number, px, %, or a function', offset));
	}

	if (!isUndefined(direction) && direction !== 'up' && direction !== 'down') {
		throw new TypeError(errorMessage('Optional', 'direction', `'up' or 'down'`, direction));
	}

	if (!(isUndefined(once) || isBoolean(once))) {
		throw new TypeError(errorMessage('Optional', 'once', 'boolean', once));
{'fraction_non_alphanumeric': 0.1408083441981747, 'fraction_numerical': 0.008148631029986962, 'mean_word_length': 4.5288288288288285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2085398', 'n_tokens_mistral': 1882, 'n_tokens_neox': 1793, 'n_words': 582}