在Angular 2应用程序中使用fuse.js(typescript)

时间:2016-11-27 21:26:20

标签: angular typescript fuse.js

我尝试在angular2应用程序中导入fuse.js,但我得到一个例外(Fuse未定义)。 我还检查包中的定义文件(index.d.ts)。

我的打字稿类是:

import 'fuse.js';

export class Myclass{

  /**some code*/

  public mySearchFunction(text, list, Opts){
    let fuseSearch  = new Fuse(list, Opts);
    let fuseResults: any[] = fuseSearch.search(text);
    return fuseResults
  }

}

我也试过

import * as Fuse from 'fuse.js';

使用此库的正确方法是什么?

1 个答案:

答案 0 :(得分:4)

这些打字仅在8天前添加到项目中。如果您查看here中的最新NPM版本,您会看到不包含这些内容。

如果您从 Print(L"Description = %s\n", (CHAR16*)buf + 3); EFI_DEVICE_PATH *BootX = (EFI_DEVICE_PATH*) (((UINT8*)buf) + (sizeof(UINT32) + sizeof(UINT16) + StrSize(buf+3))); UINTN NoHandles = 0; EFI_HANDLE *handles = NULL; EFI_GUID SimpleFileSystemGUID = SIMPLE_FILE_SYSTEM_PROTOCOL; status = uefi_call_wrapper(BS->LocateHandleBuffer, 5, ByProtocol, &SimpleFileSystemGUID, NULL, &NoHandles, &handles ); if (status != EFI_SUCCESS) Print(L"Failed to LocateHandleBuffer (%d)\n", status); else Print(L"LocateHandleBuffer OK (%d handles)\n", NoHandles); EFI_DEVICE_PATH *prefix; UINTN index; for (index = 0; index < NoHandles; index++) { prefix = DevicePathFromHandle(handles[index]); while(!IsDevicePathEnd(NextDevicePathNode(prefix))) prefix = NextDevicePathNode(prefix); if(LibMatchDevicePaths(prefix, BootX)) { break; } else { FreePool(prefix); } } prefix = DevicePathFromHandle(handles[index]); // prefix ends with the same node that BootX starts with // so skip forward BootX so we can prepend prefix BootX = NextDevicePathNode(BootX); EFI_DEVICE_PATH *fullpath = AppendDevicePath(prefix, BootX); Print(L"Booting: %s\n", DevicePathToStr(fullpath)); /* EFI_STATUS (EFIAPI *EFI_IMAGE_LOAD) ( IN BOOLEAN BootPolicy, IN EFI_HANDLE ParentImageHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle ); */ EFI_HANDLE *NextHandle = AllocateZeroPool(sizeof(EFI_HANDLE)); status = uefi_call_wrapper(BS->LoadImage, 6, /* status = BS->LoadImage( */ TRUE, /* BootPolicy */ ImageHandle, /* ParentImageHandle */ fullpath, /* DevicePath */ NULL, /* SourceBuffer */ 0, /* SourceSize */ NextHandle /* ImageHandle */ ); if (status != EFI_SUCCESS) Print(L"Failed to LoadImage (%d)\n", status); else Print(L"LoadImage OK\n"); 提取包或抓取文件template <template <class...> class T, class U, class ... Rest> void foo(const T<U, Rest...> &container) { (void)container; } master,那么您就可以使用package.json

查看控制台,我仍然收到错误index.d.ts,但它正在运行。不知道那是什么。

版本2.6.1昨天被推送到NPM,支持打字 - 请参阅here