@funnelenvy-npm/fe-dev-utils
Version:
Helper function to build client side A/B tests
38 lines (37 loc) • 1.3 kB
TypeScript
/**
* @desc set() sets a cookie with optional days
* @param {Object} options - Options object to configure the function.
* @param {String} options.name - the name of the cookie
* @param {String} options.value - the value of the cookie
* @param {Number} options.optDays - days the cookie will exist for
* NOTE: Not passing optDays will create a "Session Cookie"
* @param {String} options.domain - the domain value of the cookie
* Example: ".domain.com" would span all sub domains of domain.com
* @return {Undefined}
*
* @desc get() gets value of cookie
* @param {Object} options - Options object to configure the function.
* @param {String} options.name - name of cookie to get
* @return {String|Null} - string value of cookie NOT A BOOL!
*
* @desc del() removes cookie
* @param {Object} options - Options object to configure the function.
* @param {String} options.name - name of cookie to delete
* @return {Undefined}
*/
type CookieOptions = {
name: string;
value?: string;
optDays?: number;
domain?: string;
};
declare const cookie: {
set({ name, value, optDays, domain }: CookieOptions): void;
get({ name }: {
name: string;
}): string | null;
del({ name }: {
name: string;
}): void;
};
export default cookie;