Beispiel #1
0
 const refreshUrl = () => {
   const { filter, regulation_id, timeframe } = $scope;
   const { code, course, teachers_str, fields_str } = filter;
   url = {
     regulation: regulation_id, pm: !!filter['fields_str#~'],
     timeframe, code, course, teacher: teachers_str, field: fields_str,
   };
   url = pickBy(url);
   $location.search(url);
 };
Beispiel #2
0
    const fetchParams = () => {
      const params = $routeParams;

      $scope.filter = {
        code: params.code,
        course: params.course,
        teachers_str: params.teacher,
        fields_str: params.field,
        'fields_str#~': params.pm ? '(PM)' : null,
      };

      if (!isUndefined(params.timeframe)) {
        $scope.timeframe = params.timeframe;

        params.timeframe = params.timeframe.toLowerCase();
        if (params.timeframe.charAt(0) === 'w' || params.timeframe.charAt(0) === 's') {
          $scope.filter['term#='] = params.timeframe.charAt(0);
          params.timeframe = params.timeframe.slice(1);
        }

        // eslint-disable-next-line max-len
        const pattern = /(?:^(?:20)?(\d{2})$)|(?:(?:20)?(\d{2})([+-])(?:(?:20)?(\d{2}))?)|(?:([WS])S?(?:20)?(\d{2}))|([WS])/i;
        const r = compact(pattern.exec(trim(params.timeframe)));

        if (!isEmpty(r)) {
          if (isEmpty(r[2])) {
            $scope.filter['year#='] = `20${r[1]}`;
          } else if (r[2] === '+') {
            // year lower limit
            $scope.filter['year#<'] = `20${r[1]}`;
          } else if (r[2] === '-') {
            if (!isEmpty(r[3])) {
              // years range
              $scope.filter['year#<'] = `20${r[1]}`;
              $scope.filter['year#>'] = `20${r[3]}`;
            } else {
              // year upper limit
              $scope.filter['year#>'] = `20${r[1]}`;
            }
          }
        }
      }

      $scope.filter = pickBy($scope.filter);
      $scope.regulation_id = params.regulation ? parseInt(params.regulation, 10) : '';
    };
Beispiel #3
0
      (query, oldQuery) => {
        if (query === oldQuery) {
          return;
        }

        const match = query.match(/^([ws])?s?(\d{2,4})?:? (.*)$/i);
        if (match) {
          this.search.filter = pickBy({
            term: isEmpty(match[1]) ? '' : match[1].toUpperCase(),
            year: isEmpty(match[2]) ? '' : `20${match[2]}`.slice(-4),
            course: trim(match[3]),
          });
        } else {
          // this is just a backup if the regex above fails
          this.search.filter = { course: query };
        }

        this.applyFilter();
      },
// $ExpectError memoize retains type information
memoized = memoize(() => {});

/**
 * _.debounce
 */
var debounced: (a: number) => string = debounce((a: number) => "foo");
// $ExpectError debounce retains type information
debounced = debounce(() => {});

/**
 * _.toPairs / _.toPairsIn
 */
var pairs: [string, number][];
pairs = toPairs({ a: 12, b: 100 });
pairs = toPairsIn({ a: 12, b: 100 });

/**
 * _.pickBy
 */
(pickBy({a: 2, b: 3, c: 4}, num => num % 2): {[prop: string]: number});
(pickBy(null, num => num % 2): {});
(pickBy(undefined, num => num % 2): {});

/**
 * _.omitBy
 */
(omitBy({a: 2, b: 3, c: 4}, num => num % 2): {[prop: string]: number});
(omitBy(null, num => num % 2): {});
(omitBy(undefined, num => num % 2): {});
(matchesProperty(null, null): Function);
(merge(): {});
(mergeWith(): {});
(method(): Function);
(methodOf(): Function);
(nthArg(null): Function);
(omit(): {});
(omitBy(null, null): {});
(orderBy(null, null, null): Array<*>);
(over(): Function);
(overArgs(): Function);
(overEvery(): Function);
(overSome(): Function);
(partition(null, null): [Array<*>,Array<*>]);
(pick(): {});
(pickBy(null, null): {});
(property(null): Function);
(propertyOf(null): Function);
(pull(): void);
(pullAll(null, null): null);
(pullAllBy(null, null, null): null);
(pullAllWith(null, null, null): null);
(pullAt(): Array<*>);
(rangeRight(null, null, null): Array<*>);
(reject(null, null): Array<*>);
(remove(null, null): Array<*>);
(reverse(null): null);
(sampleSize(null, null): Array<*>);
(set(null, null, null): null);
(setWith(null, null, null, null): null);
(shuffle(null): Array<*>);