This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift | |
@_inlineable | |
public func map<T>(_ transform: (Iterator.Element) throws -> T) rethrows -> [T] { | |
// TODO: swift-3-indexing-model - review the following | |
let count: Int = numericCast(self.count) | |
if count == 0 { | |
return [] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/apple/swift/blob/master/stdlib/public/core/SequenceAlgorithms.swift.gyb | |
@_inlineable | |
public func flatMap<SegmentOfResult : Sequence>(_ transform: (${GElement}) throws -> SegmentOfResult) rethrows -> [SegmentOfResult.${GElement}] { | |
var result: [SegmentOfResult.${GElement}] = [] | |
for element in self { | |
result.append(contentsOf: try transform(element)) | |
} | |
return result | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift | |
@_inlineable | |
public func map<U>(_ transform: (Wrapped) throws -> U) rethrows -> U? { | |
switch self { | |
case .some(let y): | |
return .some(try transform(y)) | |
case .none: | |
return .none | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift | |
public enum Optional<Wrapped> : ExpressibleByNilLiteral { | |
// The compiler has special knowledge of Optional<Wrapped>, including the fact | |
// that it is an `enum` with cases named `none` and `some`. | |
/// The absence of a value. | |
/// | |
/// In code, the absence of a value is typically written using the `nil` | |
/// literal rather than the explicit `.none` enumeration case. | |
case none |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Buffer } from 'buffer' | |
var crc_table = [ | |
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, | |
0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, | |
0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, | |
0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, | |
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, | |
0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example | |
//a.js | |
// this.callback("abc") | |
Say(res) { | |
// this.callback = (result) => { | |
// console.log("result => ", result) | |
// } | |
this.callback = res; | |
// console.log("this.callback =>", this.callback) | |
// console.log("this.callback type =>", typeof(this.callback)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getQuery = "" + decodeURIComponent(options.q) | |
console.log("getQuery =>", getQuery); | |
wx.showModal({ | |
title: 'onLoad', | |
content: getQuery | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HexString2Bytes(str) { | |
var pos = 0; | |
var len = str.length; | |
if (len % 2 != 0) { | |
return null; | |
} | |
len /= 2; | |
var arrBytes = new Array(); | |
for (var i = 0; i < len; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wx.downloadFile({ | |
url: path, | |
success(res) { | |
const downloadPath = res.tempFilePath | |
console.log('downloadPath =>', downloadPath) | |
wx.openDocument({ | |
filePath: downloadPath, | |
fileType: 'pdf', | |
success(res) { | |
console.log('打开文档成功 =>', res) |