Initial implementation of func package. BUG= R=jmesserly@google.com Review URL: https://codereview.appspot.com/250790043.
diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..521fb57 --- /dev/null +++ b/LICENSE.md
@@ -0,0 +1,28 @@ + +Copyright 2015, the Dart project authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md index 8c57b30..61b2637 100644 --- a/README.md +++ b/README.md
@@ -1,2 +1,4 @@ # func -Repository for the func package containing convenience typedefs for specifying function types. +Repository for the func package containing convenience typedefs defining +commonly used function types to make it simpler to define members that return +specific function types.
diff --git a/lib/func.dart b/lib/func.dart new file mode 100644 index 0000000..041bb49 --- /dev/null +++ b/lib/func.dart
@@ -0,0 +1,29 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// Typedefs defining commonly used function types to make it simpler to +/// define members that return specific function types. +library func; + +typedef R Func0<R>(); +typedef R Func1<A, R>(A a); +typedef R Func2<A, B, R>(A a, B b); +typedef R Func3<A, B, C, R>(A a, B b, C c); +typedef R Func4<A, B, C, D, R>(A a, B b, C c, D d); + +typedef R Func1Opt1<A, R>([A a]); +typedef R Func2Opt1<A, B, R>(A a, [B b]); +typedef R Func3Opt1<A, B, C, R>(A a, B b, [C c]); +typedef R Func4Opt1<A, B, C, D, R>(A a, B b, C c, [D d]); + +typedef void VoidFunc0(); +typedef void VoidFunc1<A>(A a); +typedef void VoidFunc2<A, B>(A a, B b); +typedef void VoidFunc3<A, B, C>(A a, B b, C c); +typedef void VoidFunc4<A, B, C, D>(A a, B b, C c, D d); + +typedef void VoidFunc1Opt1<A>([A a]); +typedef void VoidFunc2Opt1<A, B>(A a, [B b]); +typedef void VoidFunc3Opt1<A, B, C>(A a, B b, [C c]); +typedef void VoidFunc4Opt1<A, B, C, D>(A a, B b, C c, [D d]);
diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..81264e1 --- /dev/null +++ b/pubspec.yaml
@@ -0,0 +1,9 @@ +name: func +version: 0.1.0 +description: > + Typedefs defining commonly used function types to make it simpler to + define members that return specific function types. +author: Dart Dev Compiler team <dev-compiler@dartlang.org> +homepage: https://github.com/dart-lang/func +environment: + sdk: ">=1.9.0 <2.0.0"