import { NEVER } from 'rxjs';
import { PACKAGE_SOURCES } from './tokens';
/**
 * Adds simple change into simple changes object
 * @param changes - Object with changes to be added to
 * @param key - Key under wich should be change stored
 * @param currentValue - Current value that is being changed
 * @param previousValue - Previous value that is being changed
 * @param firstChange - Indication whether is first change, defaults to false
 */
export function addSimpleChange(changes, key, currentValue, previousValue, firstChange = false) {
    changes[key] = {
        currentValue,
        previousValue,
        firstChange,
        isFirstChange: () => firstChange,
    };
}
/**
 * Gets provider for static package source
 * @param packageName - Name of package for which will be provider created
 */
export function provideStaticPackageSource(packageName) {
    return {
        provide: PACKAGE_SOURCES,
        useValue: {
            packages: [packageName],
            packagesChange: NEVER,
            refresh() {
            }
        },
        multi: true,
    };
}
/**
 * Gets json from its string representation
 * @param jsonString - Json string to be parsed into json
 */
export function getJson(jsonString) {
    try {
        return JSON.parse(jsonString);
    }
    catch {
        return null;
    }
}
//# sourceMappingURL=utils.js.map