UNPKG

@atomist/clj-editors

Version:

editor functions that use rewrite-clj and other important things from the clojurescript ecosystem

147 lines (140 loc) 5.63 kB
// Compiled by ClojureScript 1.10.238 {:target :nodejs} goog.provide('spec_tools.conform'); goog.require('cljs.core'); goog.require('cljs.spec.alpha'); goog.require('goog.date.UtcDateTime'); goog.require('goog.date.Date'); goog.require('clojure.set'); spec_tools.conform.string__GT_long = (function spec_tools$conform$string__GT_long(_,x){ if(typeof x === 'string'){ try{var x_SINGLEQUOTE_ = parseInt(x,(10)); if(cljs.core.truth_(isNaN(x_SINGLEQUOTE_))){ return x; } else { return x_SINGLEQUOTE_; } }catch (e27522){if((e27522 instanceof Error)){ var ___$1 = e27522; return x; } else { throw e27522; } }} else { return x; } }); spec_tools.conform.string__GT_double = (function spec_tools$conform$string__GT_double(_,x){ if(typeof x === 'string'){ try{var x_SINGLEQUOTE_ = parseFloat(x); if(cljs.core.truth_(isNaN(x_SINGLEQUOTE_))){ return x; } else { return x_SINGLEQUOTE_; } }catch (e27523){if((e27523 instanceof Error)){ var ___$1 = e27523; return x; } else { throw e27523; } }} else { return x; } }); spec_tools.conform.string__GT_keyword = (function spec_tools$conform$string__GT_keyword(_,x){ if(typeof x === 'string'){ return cljs.core.keyword.call(null,x); } else { return x; } }); spec_tools.conform.string__GT_boolean = (function spec_tools$conform$string__GT_boolean(_,x){ if(typeof x === 'string'){ if(cljs.core._EQ_.call(null,"true",x)){ return true; } else { if(cljs.core._EQ_.call(null,"false",x)){ return false; } else { return x; } } } else { return x; } }); spec_tools.conform.string__GT_uuid = (function spec_tools$conform$string__GT_uuid(_,x){ if(typeof x === 'string'){ try{if(cljs.core.truth_(cljs.core.re_find.call(null,/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,x))){ return cljs.core.uuid.call(null,x); } else { return x; } }catch (e27524){if((e27524 instanceof Error)){ var ___$1 = e27524; return x; } else { throw e27524; } }} else { return x; } }); spec_tools.conform.string__GT_date = (function spec_tools$conform$string__GT_date(_,x){ if(typeof x === 'string'){ try{return (new Date(goog.date.UtcDateTime.fromIsoString(x).getTime())); }catch (e27525){if((e27525 instanceof Error)){ var ___$1 = e27525; return x; } else { throw e27525; } }} else { return x; } }); spec_tools.conform.string__GT_symbol = (function spec_tools$conform$string__GT_symbol(_,x){ if(typeof x === 'string'){ return cljs.core.symbol.call(null,x); } else { return x; } }); spec_tools.conform.string__GT_nil = (function spec_tools$conform$string__GT_nil(_,x){ if(cljs.core._EQ_.call(null,"",x)){ return null; } else { return x; } }); spec_tools.conform.strip_extra_keys = (function spec_tools$conform$strip_extra_keys(p__27526,x){ var map__27527 = p__27526; var map__27527__$1 = ((((!((map__27527 == null)))?(((((map__27527.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27527.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27527):map__27527); var keys = cljs.core.get.call(null,map__27527__$1,new cljs.core.Keyword(null,"keys","keys",1068423698)); if(cljs.core.truth_((function (){var and__3911__auto__ = keys; if(cljs.core.truth_(and__3911__auto__)){ return cljs.core.map_QMARK_.call(null,x); } else { return and__3911__auto__; } })())){ return cljs.core.select_keys.call(null,x,keys); } else { return x; } }); spec_tools.conform.fail_on_extra_keys = (function spec_tools$conform$fail_on_extra_keys(p__27529,x){ var map__27530 = p__27529; var map__27530__$1 = ((((!((map__27530 == null)))?(((((map__27530.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27530.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27530):map__27530); var keys = cljs.core.get.call(null,map__27530__$1,new cljs.core.Keyword(null,"keys","keys",1068423698)); if(((cljs.core.map_QMARK_.call(null,x)) && (cljs.core.not.call(null,clojure.set.subset_QMARK_.call(null,cljs.core.set.call(null,cljs.core.keys.call(null,x)),keys))))){ return new cljs.core.Keyword("cljs.spec.alpha","invalid","cljs.spec.alpha/invalid",-1220295119); } else { return x; } }); spec_tools.conform.json_type_conforming = cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"keyword","keyword",811389747),spec_tools.conform.string__GT_keyword,new cljs.core.Keyword(null,"uuid","uuid",-2145095719),spec_tools.conform.string__GT_uuid,new cljs.core.Keyword(null,"date","date",-1463434462),spec_tools.conform.string__GT_date,new cljs.core.Keyword(null,"symbol","symbol",-1038572696),spec_tools.conform.string__GT_symbol], null)); spec_tools.conform.string_type_conforming = cljs.core.merge.call(null,spec_tools.conform.json_type_conforming,new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"long","long",-171452093),spec_tools.conform.string__GT_long,new cljs.core.Keyword(null,"double","double",884886883),spec_tools.conform.string__GT_double,new cljs.core.Keyword(null,"boolean","boolean",-1919418404),spec_tools.conform.string__GT_boolean,new cljs.core.Keyword(null,"nil","nil",99600501),spec_tools.conform.string__GT_nil,new cljs.core.Keyword(null,"string","string",-1989541586),null], null)); spec_tools.conform.strip_extra_keys_type_conforming = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"map","map",1371690461),spec_tools.conform.strip_extra_keys], null); spec_tools.conform.fail_on_extra_keys_type_conforming = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"map","map",1371690461),spec_tools.conform.fail_on_extra_keys], null); //# sourceMappingURL=conform.js.map