Git Product home page Git Product logo

saber-lang's Introduction

saber-lang

Bower version NPM version Build Status License EFE Mobile Team

适合 移动端 & node 环境的 语言增强 模块。

Installation

浏览器环境下,通过 edp 引入模块:

$ edp import saber-lang

node 环境下,通过 npm 引入模块:

$ npm install saber-lang --save

Usage

var lang = require('saber-lang');

var targetObj = {x: 1, y: 2};
var sourceObj = {y: 3, z: 4};
lang.extend(targetObj, sourceObj);

console.log(targetObj); // {x: 1, y: 3, z: 4}

API

Base 部分是最基础的语言增强函数,在 require('saber-lang') 时加载。

Methods

extend(target, ...source)

对象属性拷贝。

  • target {Object} 目标对象
  • source {...Object} 源对象
  • return {Object}

inherits(subClass, superClass)

为类型构造器建立继承关系。

  • subClass {Function} 子类构造器
  • superClass {Function} 父类构造器
  • return {Function}

curry(fn[, ...args])

为函数提前绑定前置参数(柯里化)。

  • fn {Function} 要绑定的函数
  • args {...*=} 函数执行时附加到执行时函数前面的参数
  • return {Function}

bind(fn, thisArg[, ...args])

为函数绑定this与前置参数。

  • fn {Function} 要绑定的函数
  • thisArg {Object} 需要绑定的this
  • args {...*=} 函数执行时附加的前置绑定参数
  • return {Function}

Optional

浏览器环境下 还提供以下可选模块,使用时需要单独引用。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.