パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリwrike/memoize_dart

memoize_dart

wrike/memoize_dart open-source repository details.

memoize_dart のプロジェクト画像
スター
27
フォーク
7
最終プッシュ(UTC)
2021/08/22
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

Memoize

memoize returns cached result of function call when inputs were not changed from previous invocation.

Warning

memoize_dart now supports dart 2.12.0 and null safety since 3.0.0 version.

For 2.0.0 we drop func as dependency. Because it archived and doesn't support dart2.

If you need dart-1.24.3 use 1.4.0 version

Examples

memo1, memo2, ... memo10 compare arguments with == operator:

import 'dart:math';
import 'package:memoize/memoize.dart';

void main() {
  var rect1 = new Rectangle<int>(0, 0, 10, 10);
  var rect2 = new Rectangle<int>(0, 0, 10, 10);

  var func = memo1((Rectangle<int> a) => a.width * a.height);

  print(func(rect1));
  print(func(rect2)); // cached result is returned
}

imemo1, imemo2, ... imemo10 compare arguments with identical function:

import 'dart:math';
import 'package:memoize/memoize.dart';

void main() {
  var rect1 = new Rectangle<int>(0, 0, 10, 10);
  var rect2 = new Rectangle<int>(0, 0, 10, 10);

  var func = imemo1((Rectangle<int> a) => a.width * a.height);

  print(func(rect1));
  print(func(rect1)); // cached - same object instance
  print(func(rect2)); // not cached - different object instance
}

memo0 caches result on first call and can be used as lazy cache:

import 'dart:math';
import 'package:memoize/memoize.dart';

void main() {
  var func = memo0(() => new Rectangle<int>(0, 0, 10, 10));

  print(func());
  print(func()); // cached - same object instance
}

Contributors

Wrike GitHub avatar
GitHub 作者

Wrike ↗

Welcome to the Wrike TechClub open source community. Let's make tech world better together! NB: members must have two-factor auth.

言語Dart

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 1 件

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗