<commit_before>import React, {forwardRef, useEffect, useImperativeHandle, useRef} from "react";
import type {bb, Chart, ChartOptions} from "billboard.js";

export interface IProp {
	bb: typeof bb;
	options: ChartOptions;
}

export interface IChart {
	instance: Chart;
}

export default forwardRef((props: IProp, ref) => {
	const container = useRef<HTMLDivElement>(null);
	const instance = useRef<Chart | null>();
	const {bb, options} = props;

	// generate chart
	const generate = () => {
		if (!instance.current) {
			options.bindto = container.current;

			// generate chart
			instance.current = bb.generate(options);
		}
	};

	useEffect(() => {
		if (!bb || !options) {
			// eslint-disable-next-line no-console
			console.warn("Required props('bb' or 'options') are not defined.");
		} else {
			generate();
		}

		// cleanup
		return () => {
			if (instance.current) {
				instance.current.destroy();
				instance.current = null;
			}
		};
	}, []);

	// customize ref to return the chart instance
	useImperativeHandle(
		ref, () => ({
			get instance() {
				return instance.current;
			}
		})
	);

	return <div ref={container} />;
});
<commit_msg>chore(packages): add copyright headear comment<commit_after>/**
 * Copyright (c) 2022 ~ present NAVER Corp.
 * @billboard.js/react project is licensed under the MIT license
 */
import React, {forwardRef, useEffect, useImperativeHandle, useRef} from "react";
import type {bb, Chart, ChartOptions} from "billboard.js";

export interface IProp {
	bb: typeof bb;
	options: ChartOptions;
}

export interface IChart {
	instance: Chart;
}

export default forwardRef((props: IProp, ref) => {
	const container = useRef<HTMLDivElement>(null);
	const instance = useRef<Chart | null>();
	const {bb, options} = props;

	// generate chart
	const generate = () => {
		if (!instance.current) {
			options.bindto = container.current;

			// generate chart
			instance.current = bb.generate(options);
		}
	};

	useEffect(() => {
		if (!bb || !options) {
			// eslint-disable-next-line no-console
			console.warn("Required props('bb' or 'options') are not defined.");
		} else {
			generate();
		}

		// cleanup
		return () => {
			if (instance.current) {
				instance.current.destroy();
				instance.current = null;
			}
		};
	}, []);

	// customize ref to return the chart instance
	useImperativeHandle(
		ref, () => ({
			get instance() {
				return instance.current;
			}
		})
	);

	return <div ref={container} />;
});

{'fraction_non_alphanumeric': 0.1533767290480065, 'fraction_numerical': 0.0016273393002441008, 'mean_word_length': 3.5036630036630036, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, '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': '4412747', 'n_tokens_mistral': 877, 'n_tokens_neox': 773, 'n_words': 207}