MCPcopy Index your code
hub / github.com/csev/py4e / configFromStringAndArray

Function configFromStringAndArray

code/gmane/Chart.bundle.js:2847–2889  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

2845 }
2846
2847 function configFromStringAndArray(config) {
2848 var tempConfig,
2849 bestMoment,
2850
2851 scoreToBeat,
2852 i,
2853 currentScore;
2854
2855 if (config._f.length === 0) {
2856 getParsingFlags(config).invalidFormat = true;
2857 config._d = new Date(NaN);
2858 return;
2859 }
2860
2861 for (i = 0; i < config._f.length; i++) {
2862 currentScore = 0;
2863 tempConfig = copyConfig({}, config);
2864 if (config._useUTC != null) {
2865 tempConfig._useUTC = config._useUTC;
2866 }
2867 tempConfig._f = config._f[i];
2868 configFromStringAndFormat(tempConfig);
2869
2870 if (!valid__isValid(tempConfig)) {
2871 continue;
2872 }
2873
2874 // if there is any input that was not parsed add a penalty for that format
2875 currentScore += getParsingFlags(tempConfig).charsLeftOver;
2876
2877 //or tokens
2878 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
2879
2880 getParsingFlags(tempConfig).score = currentScore;
2881
2882 if (scoreToBeat == null || currentScore < scoreToBeat) {
2883 scoreToBeat = currentScore;
2884 bestMoment = tempConfig;
2885 }
2886 }
2887
2888 extend(config, bestMoment || tempConfig);
2889 }
2890
2891 function configFromObject(config) {
2892 if (config._d) {

Callers 1

prepareConfigFunction · 0.85

Calls 5

getParsingFlagsFunction · 0.85
copyConfigFunction · 0.85
valid__isValidFunction · 0.85
extendFunction · 0.70

Tested by

no test coverage detected