dart-sass/lib/src/utils.dart

30 lines
787 B
Dart
Raw Normal View History

2016-05-24 03:01:15 +02:00
// Copyright 2016 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
2016-05-24 23:01:41 +02:00
import 'dart:collection';
2016-05-24 03:01:15 +02:00
import 'package:source_span/source_span.dart';
import 'ast/node.dart';
2016-06-03 22:36:20 +02:00
import 'value/number.dart';
const _epsilon = 1 / (10 * Number.precision);
2016-05-24 03:01:15 +02:00
SourceSpan spanForList(List<AstNode> nodes) {
if (nodes.isEmpty) return null;
var first = nodes.first.span;
var last = nodes.last.span;
return first is FileSpan && last is FileSpan ? first.expand(last) : null;
}
2016-05-24 23:01:41 +02:00
class LinkedListValue<T> extends LinkedListEntry<LinkedListValue<T>> {
final T value;
LinkedListValue(this.value);
}
2016-06-03 22:36:20 +02:00
bool almostEquals(num number1, num number2) =>
(number1 - number2).abs() < _epsilon;